[clang] [Clang] Avoid assertion failure for initialized extern aliases (PR #223124)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 25 06:06:48 PDT 2026
================
@@ -14127,6 +14093,15 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
return;
}
+ // handleAliasAttr() runs before the initializer is attached to the VarDecl,
+ // so it cannot determine that an extern declaration with an initializer is a
+ // definition. Diagnose the conflict now that an initializer is present and
----------------
keepyixiao wrote:
Thanks. @AaronBallman, what do you think about @efriedma-quic's interpretation that a static member variable with an alias attribute should itself be considered a definition?
If we follow that interpretation, then the out-of-line int S::i = 12; should presumably be diagnosed as a redefinition.
My thought is that the current patch should remain focused on fixing the assertion/crash caused by the alias handling. The redefinition diagnostic seems like a separate issue, so I could address that in a follow-up patch.
Would that approach make sense to you?
https://github.com/llvm/llvm-project/pull/223124
More information about the cfe-commits
mailing list