aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>2004-12-10 16:04:22 +0000
committerVolker Reichelt <reichelt@gcc.gnu.org>2004-12-10 16:04:22 +0000
commit9bf0e5888c1217afef058dbb59cb5d7824c4bba2 (patch)
tree9de3b8f1275d3a5a4b767de6d6f4b524b720fcf9 /gcc
parent417c735c222642f006a3ab29655bf20664b64f32 (diff)
downloadgcc-9bf0e5888c1217afef058dbb59cb5d7824c4bba2.zip
gcc-9bf0e5888c1217afef058dbb59cb5d7824c4bba2.tar.gz
gcc-9bf0e5888c1217afef058dbb59cb5d7824c4bba2.tar.bz2
re PR c++/18731 (ICE on invalid template declaration)
PR c++/18731 * parser.c (cp_parser_class_head): Reject typedef-name in class head. * g++.dg/parser/struct-1.C: New test. * g++.dg/parser/struct-2.C: New test. * g++.dg/parser/struct-3.C: New test. From-SVN: r91993
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/parser.c9
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/g++.dg/parse/struct-1.C4
-rw-r--r--gcc/testsuite/g++.dg/parse/struct-2.C7
-rw-r--r--gcc/testsuite/g++.dg/parse/struct-3.C10
6 files changed, 42 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 83fac5a..1abbc26e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-10 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+ PR c++/18731
+ * parser.c (cp_parser_class_head): Reject typedef-name in class head.
+
2004-12-09 Matt Austern <austern@apple.com>
PR c++/18514
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 64f468d..b728ad1 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -12620,6 +12620,15 @@ cp_parser_class_head (cp_parser* parser,
else if (nested_name_specifier)
{
tree scope;
+
+ /* Reject typedef-names in class heads. */
+ if (!DECL_IMPLICIT_TYPEDEF_P (type))
+ {
+ error ("invalid class name in declaration of %qD", type);
+ type = NULL_TREE;
+ goto done;
+ }
+
/* Figure out in what scope the declaration is being placed. */
scope = current_scope ();
/* If that scope does not contain the scope in which the
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 896b5c7..08e7221 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2004-12-10 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+ PR c++/18731
+ * g++.dg/parser/struct-1.C: New test.
+ * g++.dg/parser/struct-2.C: New test.
+ * g++.dg/parser/struct-3.C: New test.
+
2004-12-09 Richard Henderson <rth@redhat.com>
* gcc.dg/loop-3.c: Don't use i386 tuning for amd64.
diff --git a/gcc/testsuite/g++.dg/parse/struct-1.C b/gcc/testsuite/g++.dg/parse/struct-1.C
new file mode 100644
index 0000000..6e0d93a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/struct-1.C
@@ -0,0 +1,4 @@
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+// PR c++/18731
+
+template<typename T> struct T::A {}; // { dg-error "invalid class name" }
diff --git a/gcc/testsuite/g++.dg/parse/struct-2.C b/gcc/testsuite/g++.dg/parse/struct-2.C
new file mode 100644
index 0000000..b63045b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/struct-2.C
@@ -0,0 +1,7 @@
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+// PR c++/18731
+
+template<typename T> struct A
+{
+ struct T::B {}; // { dg-error "invalid class name" }
+};
diff --git a/gcc/testsuite/g++.dg/parse/struct-3.C b/gcc/testsuite/g++.dg/parse/struct-3.C
new file mode 100644
index 0000000..8e73ce4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/struct-3.C
@@ -0,0 +1,10 @@
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+// PR c++/18731
+
+struct A
+{
+ struct B;
+ typedef B C;
+};
+
+struct A::C {}; // { dg-error "invalid class name" }