fix g++.brendan/label1.C regression

Richard Henderson rth@redhat.com
Mon Mar 11 13:55:00 GMT 2002


This is another due to Jan's new sanity checks.

The problem here is that label1.C is intentionally testing for a goto
with a missing label.  So we've emitted a branch with no associated label.
Which fails a sanity check.

We have two choices here: either hack the bit of the front end that
generates the missing label error message to emit the label, or consider
that there are a class of semantic errors for which it's too much effort
to ensure that we've generated valid code, and shouldn't bother compiling
the function.

I've chosen the later.

This does affect the generation of return warnings requiring cfg analysis,
but I don't really care.  Get the semantics fixed and those come back.


r~


        * toplev.c (rest_of_compilation): Don't compile if we've had errors.

        * g++.old-deja/g++.brendan/crash52.C: Remove return warning marker.
        * g++.old-deja/g++.jason/report.C: Likewise.

Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.590
diff -c -p -d -u -r1.590 toplev.c
--- toplev.c	2002/03/11 13:27:46	1.590
+++ toplev.c	2002/03/11 21:40:06
@@ -2540,8 +2540,11 @@ rest_of_compilation (decl)
   purge_hard_subreg_sets (get_insns ());
   emit_initial_value_sets ();
 
-  /* Don't return yet if -Wreturn-type; we need to do cleanup_cfg.  */
-  if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
+  /* Early return if there were errors.  We can run afoul of our
+     consistency checks, and there's not really much point in fixing them.
+     Don't return yet if -Wreturn-type; we need to do cleanup_cfg.  */
+  if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
+      || errorcount || sorrycount)
     goto exit_rest_of_compilation;
 
   /* We may have potential sibling or tail recursion sites.  Select one
Index: testsuite/g++.old-deja/g++.brendan/crash52.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C,v
retrieving revision 1.4
diff -c -p -d -u -r1.4 crash52.C
--- crash52.C	2001/04/06 22:05:06	1.4
+++ crash52.C	2002/03/11 21:40:06
@@ -10,5 +10,4 @@ public:
 
 A &f(A &a) {// ERROR -  new decl.*
   std::cout << "Blah\n";
-} // ERROR - non-void function
-
+}
Index: testsuite/g++.old-deja/g++.jason/report.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.jason/report.C,v
retrieving revision 1.7
diff -c -p -d -u -r1.7 report.C
--- report.C	2002/02/22 11:57:49	1.7
+++ report.C	2002/03/11 21:40:06
@@ -55,7 +55,7 @@ bar2 baz (X::Y y)
   bar2 wa [5];
   wa[0] = baz(f);
   undef2 (1); // ERROR - implicit declaration
-} // ERROR - non-void
+}
 
 int ninny ()
 {
@@ -70,4 +70,4 @@ int ninny ()
 int darg (char X::*p)
 {
    undef3 (1); // ERROR - implicit declaration
-} // ERROR - non-void
+}



More information about the Gcc-patches mailing list