On Mon, Jun 20, 2011 at 10:50, Diego Novillo <dnovi...@google.com> wrote:
> On Mon, Jun 20, 2011 at 10:47, Richard Guenther
> <richard.guent...@gmail.com> wrote:
>> On Fri, Jun 17, 2011 at 5:39 PM, Jason Merrill <ja...@redhat.com> wrote:
>>>
>>> That seems reasonable to me.
>>
>> Yes.  I think Steven proposed this as well at some point.
>
> Alright, thanks.
>
> Unsurprisingly, this produces 152 failures in the testsuite.  I have
> not analyzed the reasons yet, but I hope it's just tweaking expect
> lines in the tests.

So, I think we need to re-think where to check for seen_errors().
Bailing out too early is disabling some valid diagnostics.  For
instance,

gcc/testsuite/gcc.dg/asm-7.c:
$ cat -n 
/home/dnovillo/g1/fix-4487457/Patch-752f00bd28e325efdfa0ac7abed22feb_branches-google-main/gcc/testsuite/gcc.dg/asm-7.c
     1  /* Gcc 3.3.1 deprecates memory inputs of non-lvalues.  */
     2  /* { dg-do compile } */
     3
     4  void test(void)
     5  {
     6    register int r;
     7    register int r2;
     8    int i;
     9    static int m;
    10    int *p;
    11
    12    __asm__ ("" : : "m"(r));      /* { dg-error "" } */

This error is given by the parser.

    13    __asm__ ("" : : "m"(i));
    14    __asm__ ("" : : "m"(m));
    15    __asm__ ("" : : "m"(0));      /* { dg-error "" } */
    16    __asm__ ("" : : "m"(i+1));    /* { dg-error "" } */

These two errors, however, are emitted by the gimplifier, which does
not run anymore.  The gimplifier will not run until we are in
cgraph_finalize_compilation_unit (called from
lang_hooks.decls.final_write_globals).

Ideally, we would move all diagnostics from the gimplifier into the
front end, but that seems to be a pretty hairy mess to untangle.

In looking at cgraph_finalize_compilation_unit, it seems like the
earliest we can bail out is after we've gimplified and lowered every
function.  But this means that we will do reachability analysis, which
takes me back to my original bug.

I'm thinking that the simplest fix for my release branch will be to
predicate reachability analysis with seen_errors().

For trunk, I think I would like to see us bailing out early:

diff --git a/gcc/toplev.c b/gcc/toplev.c
index 2f1a4a8..5a48b3f 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -585,7 +585,7 @@ compile_file (void)
   /* Compilation is now finished except for writing
      what's left of the symbol table output.  */

-  if (flag_syntax_only || flag_wpa)
+  if (flag_syntax_only || flag_wpa || seen_error ())
     return;

   timevar_start (TV_PHASE_GENERATE);


But this is producing several regressions in diagnostics.  Moving
those diagnostics to the parser does not look all that easy.

Thoughts?


Diego.

Reply via email to