aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2014-01-23 16:31:52 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2014-01-23 16:31:52 +0000
commitea15e254ea970653f092da0993d99b15b1f2283b (patch)
tree3b27514e1daba4a08c81b12038a6738835367068 /gcc
parentf9a4c9a61396acaea09951aa26b57375a14ac632 (diff)
downloadgcc-ea15e254ea970653f092da0993d99b15b1f2283b.zip
gcc-ea15e254ea970653f092da0993d99b15b1f2283b.tar.gz
gcc-ea15e254ea970653f092da0993d99b15b1f2283b.tar.bz2
re PR c++/58980 (ICE with invalid enum declaration)
/cp 2014-01-23 Paolo Carlini <paolo.carlini@oracle.com> PR c++/58980 * parser.c (cp_parser_enum_specifier): Handle TYPENAME_TYPE as nested_name_specifier. /testsuite 2014-01-23 Paolo Carlini <paolo.carlini@oracle.com> PR c++/58980 * g++.dg/parse/enum11.C: New. From-SVN: r206979
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c18
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/enum11.C6
4 files changed, 31 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3946901..bc49f24 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-01-23 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/58980
+ * parser.c (cp_parser_enum_specifier): Handle TYPENAME_TYPE as
+ nested_name_specifier.
+
2014-01-23 Balaji V. Iyer <balaji.v.iyer@intel.com>
* parser.c (cp_parser_direct_declarator): When Cilk Plus is enabled
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 29bfadf..c02de3b 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -15474,9 +15474,18 @@ cp_parser_enum_specifier (cp_parser* parser)
error_at (type_start_token->location, "cannot add an enumerator "
"list to a template instantiation");
+ if (TREE_CODE (nested_name_specifier) == TYPENAME_TYPE)
+ {
+ error_at (type_start_token->location,
+ "%<%T::%E%> has not been declared",
+ TYPE_CONTEXT (nested_name_specifier),
+ nested_name_specifier);
+ type = error_mark_node;
+ }
/* If that scope does not contain the scope in which the
class was originally declared, the program is invalid. */
- if (prev_scope && !is_ancestor (prev_scope, nested_name_specifier))
+ else if (prev_scope && !is_ancestor (prev_scope,
+ nested_name_specifier))
{
if (at_namespace_scope_p ())
error_at (type_start_token->location,
@@ -15485,7 +15494,8 @@ cp_parser_enum_specifier (cp_parser* parser)
type, prev_scope, nested_name_specifier);
else
error_at (type_start_token->location,
- "declaration of %qD in %qD which does not enclose %qD",
+ "declaration of %qD in %qD which does not "
+ "enclose %qD",
type, prev_scope, nested_name_specifier);
type = error_mark_node;
}
@@ -19877,12 +19887,12 @@ cp_parser_class_head (cp_parser* parser,
if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
{
/* PR59482: enter the class scope so that base-specifiers are looked
- up correctly */
+ up correctly. */
if (type)
pushclass (type);
bases = cp_parser_base_clause (parser);
/* PR59482: get out of the previously pushed class scope so that the
- subsequent pops pop the right thing */
+ subsequent pops pop the right thing. */
if (type)
popclass ();
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 43979c3..564d425 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-23 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/58980
+ * g++.dg/parse/enum11.C: New.
+
2014-01-23 Alex Velenko <Alex.Velenko@arm.com>
* gcc.target/aarch64/sshr64_1.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/parse/enum11.C b/gcc/testsuite/g++.dg/parse/enum11.C
new file mode 100644
index 0000000..68ddedb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/enum11.C
@@ -0,0 +1,6 @@
+// PR c++/58980
+
+template<typename> struct A
+{
+ enum A::B::C {}; // { dg-error "has not been declared" }
+};