re PR c++/65954 (gcc segfaults on the following input with a syntax error)
authorNathan Sidwell <nathan@acm.org>
Wed, 20 May 2015 01:54:09 +0000 (01:54 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 20 May 2015 01:54:09 +0000 (01:54 +0000)
cp/
PR c++/65954
* typeck.c (finish_class_member_access_expr): Diagnose failed
lookup of enum class member.

testsuite/
* g++.dg/cpp0x/pr65954.C: New.

From-SVN: r223430

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

index 9a3fb854123fc17f494cf47f4747e71e076bceda..cb9219dd835c08f68fff339dc84718601dc1de6a 100644 (file)
@@ -1,3 +1,9 @@
+2015-05-19  Nathan sidwell  <nathan@acm.org>
+
+       PR c++/65954
+       * typeck.c (finish_class_member_access_expr): Diagnose failed
+       lookup of enum class member.
+
 2015-05-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/66199
index a4d702b2a1d0321f55e9060c588de8f2aedc2ed8..ba99c302cde9b1af1df771b69d90d6b2b5dd454c 100644 (file)
@@ -2731,6 +2731,14 @@ finish_class_member_access_expr (tree object, tree name, bool template_p,
                  return error_mark_node;
                }
              tree val = lookup_enumerator (scope, name);
+             if (!val)
+               {
+                 if (complain & tf_error)
+                   error ("%qD is not a member of %qD",
+                          name, scope);
+                 return error_mark_node;
+               }
+             
              if (TREE_SIDE_EFFECTS (object))
                val = build2 (COMPOUND_EXPR, TREE_TYPE (val), object, val);
              return val;
index abd5364e955e556f6a9260eca8a684a82339efdb..b4d1916b514d352b74036c216baa70f78c01b21d 100644 (file)
@@ -1,3 +1,7 @@
+2015-05-19  Nathan sidwell  <nathan@acm.org>
+
+       * g++.dg/cpp0x/pr65954.C: New.
+
 2015-05-20  Oleg Endo  <olegendo@gcc.gnu.org>
 
        * gcc.target/sh/pr64366.c: Remove -m4 -ml from dg-options.
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65954.C b/gcc/testsuite/g++.dg/cpp0x/pr65954.C
new file mode 100644 (file)
index 0000000..851660b
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++11 } }
+
+struct Shape {
+  enum class Type
+  { Circle, Square };
+};
+
+
+void Foo (Shape &shape)
+{
+  +shape.Type::NOPE; // { dg-error "is not a member of" }
+}