aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/pt.cc7
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/using-enum-10.C16
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/using-enum-10a.C19
3 files changed, 36 insertions, 6 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 3169161..bc8ea06 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -17066,13 +17066,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (DECL_TEMPLATE_PARM_P (t))
return tsubst_copy (DECL_INITIAL (t), args, complain, in_decl);
- /* There is no need to substitute into namespace-scope
- enumerators. */
- if (DECL_NAMESPACE_SCOPE_P (t))
+ if (!uses_template_parms (DECL_CONTEXT (t)))
return t;
- /* If ARGS is NULL, then T is known to be non-dependent. */
- if (args == NULL_TREE)
- return scalar_constant_value (t);
/* Unfortunately, we cannot just call lookup_name here.
Consider:
diff --git a/gcc/testsuite/g++.dg/cpp2a/using-enum-10.C b/gcc/testsuite/g++.dg/cpp2a/using-enum-10.C
new file mode 100644
index 0000000..98fe064
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/using-enum-10.C
@@ -0,0 +1,16 @@
+// PR c++/103081
+// { dg-do compile { target c++20 } }
+
+enum class Pig { OINK };
+
+struct Hog {
+ using enum Pig;
+ Hog(Pig) { }
+};
+
+template<int>
+void pen() {
+ Hog(Hog::OINK);
+}
+
+template void pen<0>();
diff --git a/gcc/testsuite/g++.dg/cpp2a/using-enum-10a.C b/gcc/testsuite/g++.dg/cpp2a/using-enum-10a.C
new file mode 100644
index 0000000..daa3221
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/using-enum-10a.C
@@ -0,0 +1,19 @@
+// A version of using-enum-10.C where Hog is a template.
+// PR c++/103081
+// { dg-do compile { target c++20 } }
+
+enum class Pig { OINK };
+
+template<int>
+struct Hog {
+ using enum Pig;
+ Hog(Pig) { OINK; }
+};
+
+template<int N>
+void pen() {
+ Hog<1>(Hog<1>::OINK);
+ Hog<N>(Hog<N>::OINK);
+}
+
+template void pen<0>();