[clang] [clang] Implement CTAD for type alias template. (PR #77890)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 27 11:26:39 PST 2024
================
@@ -10598,10 +10598,36 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
if (TemplateName.isDependent())
return SubstAutoTypeDependent(TSInfo->getType());
- // We can only perform deduction for class templates.
+ // We can only perform deduction for class templates or alias templates.
auto *Template =
dyn_cast_or_null<ClassTemplateDecl>(TemplateName.getAsTemplateDecl());
+ TemplateDecl* LookupTemplateDecl = Template;
+ if (!Template && getLangOpts().CPlusPlus20) { // type alias template
----------------
hokein wrote:
We could add one for that, but I'm not sure, it seems that in general clang doesn't provide diagnostics for features that aren't available in the current `-std=` version (at least I didn't such a diagnostic).
For example, when we use C++ concepts without `-std=c++20`, clang rejects it with a diagnostic `unknown type name 'concept'`. gcc have better diagnostics (`note: 'concept' only available with '-std=c++20' or '-fconcepts'`).
I have a somewhat-relevant FIXME below, it is about to adjust `err_deduced_non_class_template_specialization_type` message to include the type-alias templates.
https://github.com/llvm/llvm-project/pull/77890
More information about the cfe-commits
mailing list