================ @@ -6295,22 +6297,36 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc); NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data()); - while (SpecLoc.getPrefix()) { + do { if (SpecLoc.getNestedNameSpecifier()->getKind() == NestedNameSpecifier::TypeSpecWithTemplate) Diag(Loc, diag::ext_template_after_declarative_nns) << FixItHint::CreateRemoval( SpecLoc.getTypeLoc().getTemplateKeywordLoc()); - SpecLoc = SpecLoc.getPrefix(); - } - // C++11 [dcl.meaning]p1: - // [...] "The nested-name-specifier of the qualified declarator-id shall - // not begin with a decltype-specifer" - if (isa_and_nonnull<DecltypeType>( - SpecLoc.getNestedNameSpecifier()->getAsType())) - Diag(Loc, diag::err_decltype_in_declarator) - << SpecLoc.getTypeLoc().getSourceRange(); + if (const Type *T = SpecLoc.getNestedNameSpecifier()->getAsType()) { + if (const auto *TST = T->getAsAdjusted<TemplateSpecializationType>()) { + // C++23 [expr.prim.id.qual]p3: + // [...] If a nested-name-specifier N is declarative and has a + // simple-template-id with a template argument list A that involves a + // template parameter, let T be the template nominated by N without A. + // T shall be a class template. + if (TST->isDependentType() && TST->isTypeAlias()) + Diag(Loc, diag::ext_alias_template_in_declarative_nns) + << SpecLoc.getLocalSourceRange(); + } else if (T->isDecltypeType()) { + // C++23 [expr.prim.id.qual]p2: + // [...] A declarative nested-name-specifier shall not have a + // decltype-specifier. + // + // FIXME: This wording appears to be defective, as it does not ---------------- sdkrystian wrote:
@erichkeane Yup, I am drafting wording for this as we speak (as well some other issues relating to declarative nested-name-specifiers) https://github.com/llvm/llvm-project/pull/80842 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits