From 3dc48db7ee66d2a7a7ed0a44a272ab0664070959 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 20 May 2015 01:54:09 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223430 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/typeck.c | 8 ++++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/pr65954.C | 12 ++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr65954.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9a3fb854123..cb9219dd835 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-05-19 Nathan sidwell + + PR c++/65954 + * typeck.c (finish_class_member_access_expr): Diagnose failed + lookup of enum class member. + 2015-05-19 Jakub Jelinek PR middle-end/66199 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a4d702b2a1d..ba99c302cde 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index abd5364e955..b4d1916b514 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-05-19 Nathan sidwell + + * g++.dg/cpp0x/pr65954.C: New. + 2015-05-20 Oleg Endo * 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 index 00000000000..851660b90a7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65954.C @@ -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" } +} -- 2.11.4.GIT