[pushed] c++: CTAD and member alias template [PR102123]
Commit Message
When building a deduction guide from the Test constructor, we need to
rewrite the use of _dummy into a dependent reference, i.e. Test<T>::template
_dummy. We were using SCOPE_REF for both type and non-type templates; we
need to use UNBOUND_CLASS_TEMPLATE for type templates.
Tested x86_64-pc-linux-gnu, applying to trunk.
PR c++/102123
gcc/cp/ChangeLog:
* pt.cc (tsubst_copy): Use make_unbound_class_template for rewriting
a type template reference.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/class-deduction110.C: New test.
---
gcc/cp/pt.cc | 3 ++
.../g++.dg/cpp1z/class-deduction110.C | 28 +++++++++++++++++++
2 files changed, 31 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp1z/class-deduction110.C
base-commit: bc86a86a4f2c057bc0e0be94dcbb8c128ae7f717
prerequisite-patch-id: 09e711b54e7911a4a04bd7808abc1b73ae4482ba
prerequisite-patch-id: 566cf0772894d0c6a842b2e0ca62eb1d5ae8ad33
prerequisite-patch-id: b1def7e83e76c1652efb483cb2b67e472d15b720
prerequisite-patch-id: 12973b1310781ff6ce5c9792ea689f0673fc5251
prerequisite-patch-id: 8dcc4ecc29dbe7b290325412af70613171456714
prerequisite-patch-id: 0e11ad2f06a4b425182bca51bd5a85eedd3ce8cd
@@ -17054,6 +17054,9 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
/* When rewriting a constructor into a deduction guide, a
non-dependent name can become dependent, so memtmpl<args>
becomes context::template memtmpl<args>. */
+ if (DECL_TYPE_TEMPLATE_P (t))
+ return make_unbound_class_template (context, DECL_NAME (t),
+ NULL_TREE, complain);
tree type = tsubst (TREE_TYPE (t), args, complain, in_decl);
return build_qualified_name (type, context, DECL_NAME (t),
/*template*/true);
new file mode 100644
@@ -0,0 +1,28 @@
+// PR c++/102123
+// { dg-do compile { target c++17 } }
+
+template<template<typename...> typename Template, typename... Args>
+struct _dummy_forwarder {
+ using type = Template<Args...>;
+};
+
+template<template<typename...> typename Template, typename... Args>
+using dummy_forwarder = typename _dummy_forwarder<Template, Args...>::type;
+
+template<typename T>
+struct Test {
+ template<typename U> using _dummy = U;
+
+ using Element = dummy_forwarder<_dummy, T>;
+
+ Element _elem;
+
+ constexpr Test(const Element elem) : _elem(elem) { }
+};
+
+template<typename T>
+Test(T) -> Test<T>;
+
+void test() {
+ const auto t = Test(1);
+}