[clang] [Clang][Sema] Diagnose use of template keyword after declarative nested-name-specifiers (PR #78595)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 30 08:06:52 PST 2024


================
@@ -6327,12 +6331,42 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC,
     return false;
   }
 
+  // C++23 [temp.names]p5:
+  //   The keyword template shall not appear immediately after a declarative
+  //   nested-name-specifier.
+  if (TemplateId && TemplateId->TemplateKWLoc.isValid()) {
+    Diag(Loc, diag::ext_template_after_declarative_nns)
+        << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc);
+  }
+
+  NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
+  while (SpecLoc.getPrefix()) {
+    // C++23 [temp.names]p5:
+    //   The keyword template shall not appear immediately after a declarative
+    //   nested-name-specifier.
+    // FIXME: nested-name-specifiers in friend declarations are declarative,
+    // but we don't call diagnoseQualifiedDeclaration for them. We should.
----------------
cor3ntin wrote:

Can you add a test for that?

https://github.com/llvm/llvm-project/pull/78595


More information about the cfe-commits mailing list