[clang] [clang][Sema] Check exported default constructors in nested classes (PR #214275)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 7 21:03:21 PDT 2026


================
@@ -6387,8 +6387,22 @@ static void checkForMultipleExportedDefaultConstructors(Sema &S,
   if (!S.Context.getTargetInfo().getCXXABI().isMicrosoft())
     return;
 
+  if (Class->isInvalidDecl())
+    return;
+
   CXXConstructorDecl *LastExportedDefaultCtor = nullptr;
   for (Decl *Member : Class->decls()) {
+    // Nested classes finish delayed default argument parsing with the outermost
+    // class, so check each nested definition and class template pattern here.
+    CXXRecordDecl *NestedClass = dyn_cast<CXXRecordDecl>(Member);
+    if (auto *NestedTemplate = dyn_cast<ClassTemplateDecl>(Member))
+      NestedClass = NestedTemplate->getTemplatedDecl();
----------------
rnk wrote:

Please file an issue. I think there are some normal patterns you can follow here:
- if class is dependent, skip
- during instantiation, call check for multiple default constructors, process all classes that are fully non-dependent

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


More information about the cfe-commits mailing list