This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix ice-on-invalid in build_throw (PR c++/28878)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 1 Sep 2006 07:27:53 -0400
- Subject: [C++ PATCH] Fix ice-on-invalid in build_throw (PR c++/28878)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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