aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>2006-07-17 04:42:24 +0000
committerVolker Reichelt <reichelt@gcc.gnu.org>2006-07-17 04:42:24 +0000
commit2a50edcd0f5cca974fe82b27a1b109618afa1a05 (patch)
tree215431855ee45679fe617055909a44fafef8e7f9 /gcc
parent23be7a669151a833b7ab99a657082ce72a9ae3fd (diff)
downloadgcc-2a50edcd0f5cca974fe82b27a1b109618afa1a05.zip
gcc-2a50edcd0f5cca974fe82b27a1b109618afa1a05.tar.gz
gcc-2a50edcd0f5cca974fe82b27a1b109618afa1a05.tar.bz2
re PR c++/28250 (ICE with invalid catch)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/except.c4
-rw-r--r--gcc/cp/name-lookup.c3
-rw-r--r--gcc/cp/parser.c13
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/eh/catch1.C8
-rw-r--r--gcc/testsuite/g++.dg/eh/catch2.C9
7 files changed, 41 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d1eb30f..821df2b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index a02fc2f..17166d9 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -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
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 43d74dc..7cc2fee 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -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))
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index a2d41f1..c422401 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 98eaa25..8b6cf37 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..7302180
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/catch1.C
@@ -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
index 0000000..33db946
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/catch2.C
@@ -0,0 +1,9 @@
+// PR c++/28250
+// { dg-do compile }
+
+void foo()
+{
+ try {}
+ catch () {} // { dg-error "before" }
+ catch (...) {}
+}