================ @@ -9895,26 +9895,30 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( if (!Template) { if (auto *AliasTemplate = dyn_cast_or_null<TypeAliasTemplateDecl>( TemplateName.getAsTemplateDecl())) { - Diag(Kind.getLocation(), - diag::warn_cxx17_compat_ctad_for_alias_templates); - LookupTemplateDecl = AliasTemplate; - auto UnderlyingType = AliasTemplate->getTemplatedDecl() - ->getUnderlyingType() - .getCanonicalType(); - // C++ [over.match.class.deduct#3]: ..., the defining-type-id of A must be - // of the form - // [typename] [nested-name-specifier] [template] simple-template-id - if (const auto *TST = - UnderlyingType->getAs<TemplateSpecializationType>()) { - Template = dyn_cast_or_null<ClassTemplateDecl>( - TST->getTemplateName().getAsTemplateDecl()); - } else if (const auto *RT = UnderlyingType->getAs<RecordType>()) { - // Cases where template arguments in the RHS of the alias are not - // dependent. e.g. - // using AliasFoo = Foo<bool>; - if (const auto *CTSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>( - RT->getAsCXXRecordDecl())) - Template = CTSD->getSpecializedTemplate(); + if (getLangOpts().CPlusPlus20) { + LookupTemplateDecl = AliasTemplate; + auto UnderlyingType = AliasTemplate->getTemplatedDecl() + ->getUnderlyingType() + .getCanonicalType(); + // C++ [over.match.class.deduct#3]: ..., the defining-type-id of A must + // be of the form + // [typename] [nested-name-specifier] [template] simple-template-id + if (const auto *TST = + UnderlyingType->getAs<TemplateSpecializationType>()) { + Template = dyn_cast_or_null<ClassTemplateDecl>( + TST->getTemplateName().getAsTemplateDecl()); + } else if (const auto *RT = UnderlyingType->getAs<RecordType>()) { + // Cases where template arguments in the RHS of the alias are not + // dependent. e.g. + // using AliasFoo = Foo<bool>; + if (const auto *CTSD = + llvm::dyn_cast<ClassTemplateSpecializationDecl>( + RT->getAsCXXRecordDecl())) + Template = CTSD->getSpecializedTemplate(); + } + } else { + Diag(Kind.getLocation(), + diag::warn_cxx17_compat_ctad_for_alias_templates); ---------------- mizvekov wrote:
This being still a warning is incompatible with the purpose of the change. https://github.com/llvm/llvm-project/pull/133597 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits