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

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 30 08:20:51 PST 2024


================
@@ -4394,8 +4394,14 @@ NestedNameSpecifierLoc TreeTransform<Derived>::TransformNestedNameSpecifierLoc(
           SS.Adopt(ETL.getQualifierLoc());
           TL = ETL.getNamedTypeLoc();
         }
-        SS.Extend(SemaRef.Context, /*FIXME:*/ SourceLocation(), TL,
-                  Q.getLocalEndLoc());
+        SourceLocation TemplateKWLoc;
+        if (const auto TSTL = TL.getAs<TemplateSpecializationTypeLoc>())
+          TemplateKWLoc = TSTL.getTemplateKeywordLoc();
+        else if (const auto DTSTL =
+                     TL.getAs<DependentTemplateSpecializationTypeLoc>())
+          TemplateKWLoc = DTSTL.getTemplateKeywordLoc();
----------------
sdkrystian wrote:

@cor3ntin Make it a function where? In `ASTContext`, `TypeLoc`, or as a non-member function? `TemplateSpecializationTypeLoc` and `DependentTemplateSpecializationTypeLoc` don't have a common base other than `TypeLoc`.

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


More information about the cfe-commits mailing list