[clang] [clang] Improved diagnostics for explicit specialization/instantiation of closure type members (PR #192843)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 29 02:30:12 PDT 2026


================
@@ -11125,12 +11047,24 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
     TSK = TSK_ExplicitInstantiationDeclaration;
 
   Specialization->setTemplateSpecializationKind(TSK, D.getIdentifierLoc());
+
   if (Specialization->isDefined()) {
     // Let the ASTConsumer know that this function has been explicitly
     // instantiated now, and its linkage might have changed.
     Consumer.HandleTopLevelDecl(DeclGroupRef(Specialization));
-  } else if (TSK == TSK_ExplicitInstantiationDefinition)
+  } else if (TSK == TSK_ExplicitInstantiationDefinition) {
+    // C++2c [expr.prim.lambda#closure-19] A member of a closure type shall not
+    // be explicitly instantiated.
+    if (CXXRecordDecl *RD =
----------------
tbaederr wrote:

```suggestion
    if (const auto *RD =
```

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


More information about the cfe-commits mailing list