On 3/9/22 10:39, Patrick Palka wrote:
On Tue, 8 Mar 2022, Jason Merrill wrote:
On 3/2/22 14:32, Patrick Palka wrote:
In order to be able to perform CTAD for a dependently-scoped template
such as A<T>::B in the testcase below, we need to permit a
typename-specifier to resolve to a template as per [dcl.type.simple]/2,
at least when it appears in a CTAD-enabled context.
This patch implements this using a new tsubst flag tf_tst_ok to control
when a TYPENAME_TYPE is allowed to name a template, and sets this flag
when substituting into the type of a CAST_EXPR, CONSTRUCTOR or VAR_DECL
(each of which is a CTAD-enabled context).
What breaks if we always allow that, or at least in -std that support CTAD?
AFAICT no significant breakage, but some accepts-invalid and diagnostic
regressions crop up, e.g. accepts-invalid for
using type = typename A<T>::B; // no more diagnostic if typename resolves to
a
// template at instantiation time
and diagnostic regression for
template<class T, class = typename A<T>::B> void f();
// no more elaboration why deduction failed if typename resolves
// to a template
Ah, sure, the cost is that we would need to check for this case in
various callers, rather than setting a flag in a different set of
callers. Fair enough.
@@ -16229,6 +16237,12 @@ tsubst (tree t, tree args, tsubst_flags_t complain,
tree in_decl)
}
}
+ if (TREE_CODE (f) == TEMPLATE_DECL)
+ {
+ gcc_checking_assert (tst_ok);
+ f = make_template_placeholder (f);
+ }
How about calling make_template_placeholder in make_typename_type?
Jason