[clang] [Clang] Fix "Unions cannot be dynamic classes" assertion (PR #217942)

Shengxin Pei via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 01:11:40 PDT 2026


================
@@ -6585,6 +6585,9 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D,
           return nullptr;
 
         D.setInvalidType();
+      } else if (CurContext->isRecord() && !CurContext->Equals(DC)) {
+        // Keep the diagnosed declaration for recovery, but not as a valid one.
----------------
TPPPP72 wrote:

If the final fix is ​​confirmed to be this approach, then I don't think this comment is necessary, as it is self-evident.

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


More information about the cfe-commits mailing list