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]

[patch] Fix PR c++/28250: ICE with invalid catch


The following invalid code snippet causes an ICE on mainline:

  template<int> void foo()
  {
    try {}
    catch (int(0)) {}
  }

bug.cc: In function 'void foo()':
bug.cc:4: error: expected `)' before numeric constant
bug.cc:4: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'error_mark'  in pushdecl_maybe_friend, at cp/name-lookup.c:574
Please submit a full bug report, [etc.]

The patch below fixes this by replacing an invalid decl in
finish_handler_parms by a NULL_TREE (which indicates a "...").

The ICE currently only happens if processing_template_decl is set,
but doing the replacement unconditionally might save us future trouble.

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

Regards,
Volker

:ADDPATCH C++:


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

	PR c++/28250
	* semantics.c (finish_handler_parms): Treat invalid DECL as `...'.

===================================================================
--- gcc/gcc/cp/semantics.c	(revision 115140)
+++ gcc/gcc/cp/semantics.c	(working copy)
@@ -1077,6 +1077,11 @@ finish_handler_parms (tree decl, tree handler)
 finish_handler_parms (tree decl, tree handler)
 {
   tree type = NULL_TREE;
+
+  /* Treat invalid DECL as `...'.  */
+  if (decl == error_mark_node)
+    decl = NULL_TREE;
+
   if (processing_template_decl)
     {
       if (decl)
===================================================================

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

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

===================================================================
--- gcc/gcc/testsuite/g++.dg/eh/catch1.C	2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/eh/catch1.C	2006-07-03 18:58:57 +0200
@@ -0,0 +1,8 @@
+// PR c++/28250
+// { dg-do compile }
+
+template<int> void foo()
+{
+  try {}
+  catch (int(0)) {}  // { dg-error "before" }
+}
===================================================================



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