[clang] [Clang] use parameter location for abbreviated function templates (PR #129139)

Oleksandr T. via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 5 01:51:27 PST 2025


================
@@ -7991,8 +7991,12 @@ Sema::CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams) {
   //   have C linkage.
   DeclContext *Ctx = S->getEntity();
   if (Ctx && Ctx->isExternCContext()) {
-    Diag(TemplateParams->getTemplateLoc(), diag::err_template_linkage)
-        << TemplateParams->getSourceRange();
+    SourceRange Range =
+        TemplateParams->getTemplateLoc().isInvalid() && TemplateParams->size()
+            ? TemplateParams->getParam(TemplateParams->size() - 1)
+                  ->getSourceRange()
----------------
a-tarasyuk wrote:

@cor3ntin thanks for the review. The decision to retrieve the last parameter was driven by the following comment for this helper https://github.com/llvm/llvm-project/blob/36cd60144b15dd35c8e0081100421c3511242e02/clang/include/clang/AST/DeclTemplate.h#L1091

Or better to use first param? 



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


More information about the cfe-commits mailing list