]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/28250 (ICE with invalid catch)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Mon, 17 Jul 2006 04:42:24 +0000 (04:42 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Mon, 17 Jul 2006 04:42:24 +0000 (04:42 +0000)
PR c++/28250
* name-lookup.c (pushdecl_maybe_friend): Return early on
error_mark_node.
* except.c (expand_start_catch_block): Use error_mark_node instead
of NULL_TREE for invalid decls.
* parser.c (cp_parser_exception_declaration): Return error_mark_node
on invalid catch parameter. Simplify.

* g++.dg/eh/catch1.C: New test.
* g++.dg/eh/catch2.C: New test.

From-SVN: r115516

gcc/cp/ChangeLog
gcc/cp/except.c
gcc/cp/name-lookup.c
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/eh/catch1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/eh/catch2.C [new file with mode: 0644]

index d1eb30fea24edb8e3fe20e11993d0451c08f06bf..821df2bde78ea3a6c8b88a5571c7dd82caf845ba 100644 (file)
@@ -1,3 +1,13 @@
+2006-07-17  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/28250
+       * name-lookup.c (pushdecl_maybe_friend): Return early on
+       error_mark_node.
+       * except.c (expand_start_catch_block): Use error_mark_node instead
+       of NULL_TREE for invalid decls.
+       * parser.c (cp_parser_exception_declaration): Return error_mark_node
+       on invalid catch parameter. Simplify.
+
 2006-07-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/28370
index a02fc2f5533cfdd31ee93cb1723cd7ed88e8cb3d..17166d92af0d93fdf18797e0cb964edfa2001941 100644 (file)
@@ -412,7 +412,7 @@ expand_start_catch_block (tree decl)
 
   /* Make sure this declaration is reasonable.  */
   if (decl && !complete_ptr_ref_or_void_ptr_p (TREE_TYPE (decl), NULL_TREE))
-    decl = NULL_TREE;
+    decl = error_mark_node;
 
   if (decl)
     type = prepare_eh_type (TREE_TYPE (decl));
@@ -438,7 +438,7 @@ expand_start_catch_block (tree decl)
 
   /* If there's no decl at all, then all we need to do is make sure
      to tell the runtime that we've begun handling the exception.  */
-  if (decl == NULL)
+  if (decl == NULL || decl == error_mark_node)
     finish_expr_stmt (do_begin_catch ());
 
   /* If the C++ object needs constructing, we need to do that before
index 43d74dc968e771b1c8b0cda88c8460c6c9fdae98..7cc2fee53291bfa46050466f564608adff765744 100644 (file)
@@ -569,6 +569,9 @@ pushdecl_maybe_friend (tree x, bool is_friend)
 
   timevar_push (TV_NAME_LOOKUP);
 
+  if (x == error_mark_node)
+    POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
+
   need_new_binding = 1;
 
   if (DECL_TEMPLATE_PARM_P (x))
index a2d41f164a7958d84d0ddd450a324b28cfa15cf8..c4224019da7eccb56159caaf03c73db794fa17e0 100644 (file)
@@ -14343,7 +14343,6 @@ cp_parser_handler (cp_parser* parser)
 static tree
 cp_parser_exception_declaration (cp_parser* parser)
 {
-  tree decl;
   cp_decl_specifier_seq type_specifiers;
   cp_declarator *declarator;
   const char *saved_message;
@@ -14376,16 +14375,10 @@ cp_parser_exception_declaration (cp_parser* parser)
   /* Restore the saved message.  */
   parser->type_definition_forbidden_message = saved_message;
 
-  if (type_specifiers.any_specifiers_p)
-    {
-      decl = grokdeclarator (declarator, &type_specifiers, CATCHPARM, 1, NULL);
-      if (decl == NULL_TREE)
-       error ("invalid catch parameter");
-    }
-  else
-    decl = NULL_TREE;
+  if (!type_specifiers.any_specifiers_p)
+    return error_mark_node;
 
-  return decl;
+  return grokdeclarator (declarator, &type_specifiers, CATCHPARM, 1, NULL);
 }
 
 /* Parse a throw-expression.
index 98eaa25b066650f78e6a08f88fec472b0e5b51d9..8b6cf37bd739817a1541da8eaac6e55413b800d4 100644 (file)
@@ -1,3 +1,9 @@
+2006-07-17  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/28250
+       * g++.dg/eh/catch1.C: New test.
+       * g++.dg/eh/catch2.C: New test.
+
 2006-07-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/28370
diff --git a/gcc/testsuite/g++.dg/eh/catch1.C b/gcc/testsuite/g++.dg/eh/catch1.C
new file mode 100644 (file)
index 0000000..7302180
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/28250
+// { dg-do compile }
+
+template<int> void foo()
+{
+  try {}
+  catch (int(0)) {}  // { dg-error "before" }
+}
diff --git a/gcc/testsuite/g++.dg/eh/catch2.C b/gcc/testsuite/g++.dg/eh/catch2.C
new file mode 100644 (file)
index 0000000..33db946
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/28250
+// { dg-do compile }
+
+void foo()
+{
+  try {}
+  catch () {}  // { dg-error "before" }
+  catch (...) {}
+}
This page took 0.125082 seconds and 5 git commands to generate.