From 1a142d6e6858e6fb58bab8592ee1223621867f1e Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 1 May 2018 14:11:53 -0400 Subject: [PATCH] PR c++/85587 - error with scoped enum in template. * semantics.c (finish_qualified_id_expr): Don't return an unqualified IDENTIFIER_NODE. From-SVN: r259805 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 3 ++- gcc/testsuite/g++.dg/cpp0x/scoped_enum8.C | 25 +++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/scoped_enum8.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3453df8aa18..604e704fb2c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-05-01 Jason Merrill + + PR c++/85587 - error with scoped enum in template. + * semantics.c (finish_qualified_id_expr): Don't return an + unqualified IDENTIFIER_NODE. + 2018-04-30 Jason Merrill PR c++/85580 - extern "C" and local variables diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 8c893ed64b0..4568bb96f3b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2061,7 +2061,8 @@ finish_qualified_id_expr (tree qualifying_class, } /* No need to check access within an enum. */ - if (TREE_CODE (qualifying_class) == ENUMERAL_TYPE) + if (TREE_CODE (qualifying_class) == ENUMERAL_TYPE + && TREE_CODE (expr) != IDENTIFIER_NODE) return expr; /* Within the scope of a class, turn references to non-static diff --git a/gcc/testsuite/g++.dg/cpp0x/scoped_enum8.C b/gcc/testsuite/g++.dg/cpp0x/scoped_enum8.C new file mode 100644 index 00000000000..3bd66395787 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/scoped_enum8.C @@ -0,0 +1,25 @@ +// PR c++/85587 +// { dg-do compile { target c++11 } } + +template +struct S +{ + enum class T + { + E, F + }; + void foo (); +}; + +template +void S::foo () +{ + decltype (T::F) t; +} + +void +bar () +{ + S<0> s; + s.foo (); +} -- 2.30.2