]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/58980 (ICE with invalid enum declaration)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 23 Jan 2014 16:31:52 +0000 (16:31 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 23 Jan 2014 16:31:52 +0000 (16:31 +0000)
/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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/enum11.C [new file with mode: 0644]

index 3946901cfc1723adcb666cd5240b3160c0e116fe..bc49f24482565028ec734996ce462b4b905809c5 100644 (file)
@@ -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
index 29bfadf3fbb29609a256d5545e686a4f6dd60922..c02de3bf9edcd681d8aea1838e85c744cbd298a8 100644 (file)
@@ -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 ();
     }
index 43979c3603bebc0e76168c95294ce64765165328..564d4258c7b1c088ada21d394449f1650ab7412d 100644 (file)
@@ -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 (file)
index 0000000..68ddedb
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/58980
+
+template<typename> struct A
+{ 
+  enum A::B::C {};   // { dg-error "has not been declared" }
+};