re PR c++/47635 ([C++0x] ICE on invalid code in constructor_name_p, at cp/name-lookup...
authorJason Merrill <jason@redhat.com>
Mon, 20 Jun 2011 14:40:29 +0000 (10:40 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 20 Jun 2011 14:40:29 +0000 (10:40 -0400)
PR c++/47635
* decl.c (grokdeclarator): Don't set ctype to an ENUMERAL_TYPE.

From-SVN: r175216

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/enum20.C [new file with mode: 0644]

index d88dc6089dac6b17e039c34a56cbb1af96310226..9269a759d347a8313d0de5a7708963ecde377f2a 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-20  Jason Merrill  <jason@redhat.com>
 
+       PR c++/47635
+       * decl.c (grokdeclarator): Don't set ctype to an ENUMERAL_TYPE.
+
        PR c++/48138
        * tree.c (strip_typedefs): Use build_aligned_type.
 
index 85249f114804b3a33f5960290d576a2501b60243..263ab3fdafe2a32a45f1cc4650171e2aef8dcbd7 100644 (file)
@@ -8338,10 +8338,15 @@ grokdeclarator (const cp_declarator *declarator,
                else if (TYPE_P (qualifying_scope))
                  {
                    ctype = qualifying_scope;
-                   if (innermost_code != cdk_function
-                       && current_class_type
-                       && !UNIQUELY_DERIVED_FROM_P (ctype,
-                                                    current_class_type))
+                   if (!MAYBE_CLASS_TYPE_P (ctype))
+                     {
+                       error ("%q#T is not a class or a namespace", ctype);
+                       ctype = NULL_TREE;
+                     }
+                   else if (innermost_code != cdk_function
+                            && current_class_type
+                            && !UNIQUELY_DERIVED_FROM_P (ctype,
+                                                         current_class_type))
                      {
                        error ("type %qT is not derived from type %qT",
                               ctype, current_class_type);
@@ -9350,7 +9355,7 @@ grokdeclarator (const cp_declarator *declarator,
      would not have exited the loop above.  */
   if (declarator
       && declarator->u.id.qualifying_scope
-      && TYPE_P (declarator->u.id.qualifying_scope))
+      && MAYBE_CLASS_TYPE_P (declarator->u.id.qualifying_scope))
     {
       tree t;
 
@@ -10156,13 +10161,6 @@ grokdeclarator (const cp_declarator *declarator,
                       "declared out of global scope", name);
          }
 
-       if (ctype != NULL_TREE
-           && TREE_CODE (ctype) != NAMESPACE_DECL && !MAYBE_CLASS_TYPE_P (ctype))
-         {
-           error ("%q#T is not a class or a namespace", ctype);
-           ctype = NULL_TREE;
-         }
-
        if (ctype == NULL_TREE)
          {
            if (virtualp)
index 99d4d3d410a60f59182bd808f303c24ebc5d472d..337e5f9a2f46e86e9cc5ef8442c66c7b11ea0d3c 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-20  Jason Merrill  <jason@redhat.com>
 
+       PR c++/47635
+       * g++.dg/cpp0x/enum20.C: New.
+
        PR c++/48138
        * g++.dg/ext/attr-aligned01.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/enum20.C b/gcc/testsuite/g++.dg/cpp0x/enum20.C
new file mode 100644 (file)
index 0000000..e5dc186
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/47635
+// { dg-options -std=c++0x }
+
+enum A { };
+void A::f() { }                        // { dg-error "not a class" }