This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] More fallout from Fix PR c++/28250: ICE with invalid catch


On 24 Jul, Mark Mitchell wrote:
> Volker Reichelt wrote:
> 
>>> Why do you want to exit early here?
>> 
>> Because later in cp_finish_file we have
>> 
>>   cgraph_finalize_compilation_unit ();
>>   cgraph_optimize ();
>> 
>> If I don't skip these, I get ICEs from the middle-end.
> 
> I think it would be better to put the checks into those functions.  That
> bullet-proofs all front ends that use these functions.  In general, it
> would be best if the front ends didn't have to do these sorts of checks.

OK, here we go.
Now also with some testcases included.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline?

Regards,
Volker

:ADDPATCH C++:


2006-07-26  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/28250
	PR c++/28257
	PR c++/28259
	PR c++/28267
	* toplev.c (compile_file): Return early on errorcount or
	sorrycount.
	* cgraphunit.c (cgraph_finalize_compilation_unit): Likewise.
	(cgraph_optimize): Likewise.

===================================================================
--- gcc/gcc/toplev.c	(revision 115731)
+++ gcc/gcc/toplev.c	(working copy)
@@ -1006,7 +1006,7 @@ compile_file (void)
      what's left of the symbol table output.  */
   timevar_pop (TV_PARSE);
 
-  if (flag_syntax_only)
+  if (flag_syntax_only || errorcount || sorrycount)
     return;
 
   lang_hooks.decls.final_write_globals ();
===================================================================
--- gcc/gcc/cgraphunit.c	(revision 115731)
+++ gcc/gcc/cgraphunit.c	(working copy)
@@ -1015,6 +1015,9 @@ cgraph_finalize_compilation_unit (void)
   static struct cgraph_node *first_analyzed;
   static struct cgraph_varpool_node *first_analyzed_var;
 
+  if (errorcount || sorrycount)
+    return;
+
   finish_aliases_1 ();
 
   if (!flag_unit_at_a_time)
@@ -1462,6 +1465,9 @@ cgraph_optimize (void)
 void
 cgraph_optimize (void)
 {
+  if (errorcount || sorrycount)
+    return;
+
 #ifdef ENABLE_CHECKING
   verify_cgraph ();
 #endif
===================================================================

2006-07-26  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/28250
	* g++.dg/eh/catch4.C: New test.

	PR c++/28257
	* g++.dg/other/qual1.C: New test.

	PR c++/28259
	* g++.dg/inherit/error2.C: New test.

	PR c++/28267
	* g++.dg/other/new1.C: New test.

===================================================================
--- gcc/gcc/testsuite/g++.dg/eh/catch4.C	2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/eh/catch4.C	2006-07-26 13:01:34 +0200
@@ -0,0 +1,8 @@
+// PR c++/28250
+// { dg-do compile }
+
+void foo()
+{
+  try { throw; }
+  catch () {}  // { dg-error "type-specifier" }
+}
===================================================================
--- gcc/gcc/testsuite/g++.dg/other/qual1.C	2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/other/qual1.C	2006-07-26 13:02:03 +0200
@@ -0,0 +1,11 @@
+// PR c++/28257
+// { dg-do compile }
+
+struct A
+{
+  int i;
+  void foo()
+  {
+    int A::i = i;  // { dg-error "extra qualification|not a static member" }
+  }
+};
===================================================================
--- gcc/gcc/testsuite/g++.dg/inherit/error2.C	2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/inherit/error2.C	2006-07-26 13:02:55 +0200
@@ -0,0 +1,16 @@
+// PR c++/28259
+// { dg-do compile }
+
+struct A
+{
+  virtual A* foo();
+};
+
+struct B : virtual A;  // { dg-error "before" }
+
+struct C : A
+{
+  virtual B* foo();
+};
+
+B* C::foo() { return 0; }
===================================================================
--- gcc/gcc/testsuite/g++.dg/other/new1.C	2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/other/new1.C	2006-07-26 13:03:33 +0200
@@ -0,0 +1,14 @@
+// PR c++/28267
+// { dg-do compile }
+
+struct A
+{
+  A();
+  void* operator new(__SIZE_TYPE__, int = X);  // { dg-error "not declared" }
+  void operator delete(void*, int);
+};
+
+void foo()
+{
+  new A;
+}
===================================================================



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]