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]

[C++ PATCH] Fix ice-on-invalid in build_throw (PR c++/28878)


Hi!

In the testcase build_throw is called with processing_template_decl,
but with cfun == NULL (as there is a typo).
All other places that touch current_function_returns_abnormally
(which is cfun->language->returns_abnormally) are guarded with if (... && cfun),
so I think doing it here too is the right fix.

Ok for trunk/4.1?

2006-09-01  Jakub Jelinek  <jakub@redhat.com>

	PR c++/28878
	* except.c (build_throw): Only set current_function_returns_abnormally
	if cfun is not NULL.

	* g++.dg/parse/crash33.C: New test.

--- gcc/cp/except.c.jj	2006-08-29 16:34:45.000000000 +0200
+++ gcc/cp/except.c	2006-09-01 12:49:12.000000000 +0200
@@ -605,7 +605,8 @@ build_throw (tree exp)
 
   if (processing_template_decl)
     {
-      current_function_returns_abnormally = 1;
+      if (cfun)
+	current_function_returns_abnormally = 1;
       return build_min (THROW_EXPR, void_type_node, exp);
     }
 
--- gcc/testsuite/g++.dg/parse/crash33.C.jj	2006-09-01 12:50:48.000000000 +0200
+++ gcc/testsuite/g++.dg/parse/crash33.C	2006-09-01 12:51:56.000000000 +0200
@@ -0,0 +1,8 @@
+// PR c++/28878
+// { dg-do compile }
+
+template<int>
+void foo()
+[
+  throw;	// { dg-error "expected" }
+}		// { dg-error "expected" }

	Jakub


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