From: Nathan Sidwell Date: Wed, 20 May 2015 01:54:09 +0000 (+0000) Subject: re PR c++/65954 (gcc segfaults on the following input with a syntax error) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=09b59d4de67fdf03f1263fd16ec7949dabcdebcf;p=gcc.git re PR c++/65954 (gcc segfaults on the following input with a syntax error) 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 --- 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" } +}