aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2004-12-02 13:35:15 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2004-12-02 13:35:15 +0000
commit55dcbc1297c0c6212c99412ca30de1c204964f02 (patch)
tree378e86f8b21ad22c0ba9cd81f09bf030e8492e22
parent9b8d9ac39f3183ec65a452cc0bc9de7f546eab85 (diff)
downloadgcc-55dcbc1297c0c6212c99412ca30de1c204964f02.zip
gcc-55dcbc1297c0c6212c99412ca30de1c204964f02.tar.gz
gcc-55dcbc1297c0c6212c99412ca30de1c204964f02.tar.bz2
re PR c++/18758 (ICE redeclaring struct as template)
cp: PR c++/18758 * parser.c (cp_parser_class_head): Return NULL_TREE when push_template_decl fails. Update comment. testsuite: PR 18758 * g++.dg/parse/crash21.C: New. From-SVN: r91636
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c12
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/crash21.C7
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4a48637..dc158b0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-02 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/18758
+ * parser.c (cp_parser_class_head): Return NULL_TREE when
+ push_template_decl fails. Update comment.
+
2004-12-02 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/15664, c++/18276
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 51b8f10..cf96406 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -12443,6 +12443,8 @@ cp_parser_class_specifier (cp_parser* parser)
*NESTED_NAME_SPECIFIER_P to TRUE iff one of the productions
involving a nested-name-specifier was used, and FALSE otherwise.
+ Returns error_mark_node if this is not a class-head.
+
Returns NULL_TREE if the class-head is syntactically valid, but
semantically invalid in a way that means we should skip the entire
body of the class. */
@@ -12714,7 +12716,15 @@ cp_parser_class_head (cp_parser* parser,
type = TYPE_MAIN_DECL (TREE_TYPE (type));
if (PROCESSING_REAL_TEMPLATE_DECL_P ()
&& !CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (type)))
- type = push_template_decl (type);
+ {
+ type = push_template_decl (type);
+ if (type == error_mark_node)
+ {
+ type = NULL_TREE;
+ goto done;
+ }
+ }
+
type = TREE_TYPE (type);
if (nested_name_specifier)
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c55808a..42c4c5b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-02 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR 18758
+ * g++.dg/parse/crash21.C: New.
+
2004-12-02 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/15664, c++/18276
diff --git a/gcc/testsuite/g++.dg/parse/crash21.C b/gcc/testsuite/g++.dg/parse/crash21.C
new file mode 100644
index 0000000..283f6b4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/crash21.C
@@ -0,0 +1,7 @@
+namespace N
+{
+ struct A; // { dg-error "previous declaration" "" }
+}
+
+template<int I>
+struct N::A {}; // { dg-error "redeclared" "" }