diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index c7aee66f068..580c3fc2cb2 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -30338,13 +30338,14 @@ alias_ctad_tweaks (tree tmpl, tree uguides) any). */ enum { alias, inherited } ctad_kind; - tree atype, fullatparms, utype; + tree atype, fullatparms, utype, name; if (TREE_CODE (tmpl) == TEMPLATE_DECL) { ctad_kind = alias; atype = TREE_TYPE (tmpl); fullatparms = DECL_TEMPLATE_PARMS (tmpl); utype = DECL_ORIGINAL_TYPE (DECL_TEMPLATE_RESULT (tmpl)); + name = dguide_name (tmpl); } else { @@ -30352,6 +30353,8 @@ alias_ctad_tweaks (tree tmpl, tree uguides) atype = NULL_TREE; fullatparms = TREE_PURPOSE (tmpl); utype = TREE_VALUE (tmpl); + name = dguide_name (TPARMS_PRIMARY_TEMPLATE + (INNERMOST_TEMPLATE_PARMS (fullatparms))); } tsubst_flags_t complain = tf_warning_or_error; @@ -30447,6 +30450,7 @@ alias_ctad_tweaks (tree tmpl, tree uguides) } if (g == error_mark_node) continue; + DECL_NAME (g) = name; if (nfparms == 0) { /* The targs are all non-dependent, so g isn't a template. */ diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias22.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias22.C new file mode 100644 index 00000000000..9c6c841166a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias22.C @@ -0,0 +1,14 @@ +// PR c++/115198 +// { dg-do compile { target c++20 } } + +template +struct C { + C() = default; + C(const C&) = default; +}; + +template +using A = C; + +C c; +A a = c; // { dg-bogus "ambiguous" }