re PR c++/51588 ([c++0x] [4.4/4.5/4.6/4.7 Regression] ICE using an enum as base class)
authorJason Merrill <jason@redhat.com>
Sun, 18 Dec 2011 00:55:18 +0000 (19:55 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 18 Dec 2011 00:55:18 +0000 (19:55 -0500)
PR c++/51588
* parser.c (cp_parser_ptr_operator): Reject pointer to member of enum.

From-SVN: r182452

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

index 4faf0010a014508bb1865fb1e0db72d9f022c0be..18f1dfdd6bdb6a1308ffa134fe0aeb4687b52d5a 100644 (file)
@@ -1,3 +1,8 @@
+2011-12-17  Jason Merrill  <jason@redhat.com>
+
+       PR c++/51588
+       * parser.c (cp_parser_ptr_operator): Reject pointer to member of enum.
+
 2011-12-17  Richard Henderson  <rth@redhat.com>
 
        PR bootstrap/51072
index ac7427e5e85ce70409182994458879da9d04b604..51d04d46fc07e9176f64916f24a0364d4bb75db5 100644 (file)
@@ -16448,6 +16448,9 @@ cp_parser_ptr_operator (cp_parser* parser,
 
          if (TREE_CODE (parser->scope) == NAMESPACE_DECL)
            error_at (token->location, "%qD is a namespace", parser->scope);
+         else if (TREE_CODE (parser->scope) == ENUMERAL_TYPE)
+           error_at (token->location, "cannot form pointer to member of "
+                     "non-class %q#T", parser->scope);
          else
            {
              /* The type of which the member is a member is given by the
index 066121dcd36f1e9e8b226371deb515a67b616900..235f8c965b5d85cd9a5302428b131d50c91eb2cb 100644 (file)
@@ -1,5 +1,8 @@
 2011-12-17  Jason Merrill  <jason@redhat.com>
 
+       PR c++/51588
+       * g++.dg/parse/enum7.C: New.
+
        PR c++/51586
        * g++.dg/lookup/nested2.C: New.
 
diff --git a/gcc/testsuite/g++.dg/parse/enum7.C b/gcc/testsuite/g++.dg/parse/enum7.C
new file mode 100644 (file)
index 0000000..d9e3a89
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/51588
+
+enum A {};
+
+struct B : A {                 // { dg-error "" }
+  int i;
+};
+
+int A::* p = &B::i;            // { dg-error "" }