PR c++/85587 - error with scoped enum in template.
authorJason Merrill <jason@redhat.com>
Tue, 1 May 2018 18:11:53 +0000 (14:11 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 1 May 2018 18:11:53 +0000 (14:11 -0400)
* semantics.c (finish_qualified_id_expr): Don't return an
unqualified IDENTIFIER_NODE.

From-SVN: r259805

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

index 3453df8..604e704 100644 (file)
@@ -1,3 +1,9 @@
+2018-05-01  Jason Merrill  <jason@redhat.com>
+
+       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  <jason@redhat.com>
 
        PR c++/85580 - extern "C" and local variables
index 8c893ed..4568bb9 100644 (file)
@@ -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 (file)
index 0000000..3bd6639
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/85587
+// { dg-do compile { target c++11 } }
+
+template <int N>
+struct S
+{
+  enum class T
+  {
+    E, F
+  };
+  void foo ();
+};
+
+template <int N>
+void S<N>::foo ()
+{
+  decltype (T::F) t;
+}
+
+void
+bar ()
+{
+  S<0> s;
+  s.foo ();
+}