================
@@ -8229,24 +8229,37 @@ Sema::CheckTemplateDeclScope(Scope *S, 
TemplateParameterList *TemplateParams) {
   // C++ [temp.class.spec]p6: [P2096]
   //   A partial specialization may be declared in any scope in which the
   //   corresponding primary template may be defined.
+  auto FindTemplateParamsLoc = [](TemplateParameterList *TemplateParams,
+                                  SourceLocation Fallback) {
+    SourceLocation DiagLoc = TemplateParams->getTemplateLoc();
+    if (DiagLoc.isValid())
+      return DiagLoc;
+
+    for (const NamedDecl *Param : *TemplateParams)
+      if (Param && Param->getLocation().isValid())
+        return Param->getLocation();
+
+    return Fallback;
+  };
+
   if (Ctx) {
     if (Ctx->isFileContext())
       return false;
     if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Ctx)) {
       // C++ [temp.mem]p2:
       //   A local class shall not have member templates.
-      if (RD->isLocalClass())
-        return Diag(TemplateParams->getTemplateLoc(),
+      if (RD->isLocalClass()) {
----------------
ojhunt wrote:

While I also prefer braces around multi line statements the style rules say no 
braces :-/

https://github.com/llvm/llvm-project/pull/149781
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to