================
@@ -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
----------------
AaronBallman wrote:
> So I'm a little unsure how this declaration should be classified in this case.
You're in good company, I was struggling with that yesterday too. :-D Because
the purpose to alias is to say "this declaration is just another name for that
object definition over there", I think putting the alias attribute on the
static data member makes sense because that's just a declaration. But that
means an out-of-line definition for it would be invalid because it stops being
a declaration and starts being a definition at that point. For example, this
shows that we correctly treat it as a declaration without the out-of-line
definition and has the expected semantics: https://godbolt.org/z/cq9hTxdKE
CC @efriedma-quic for a second opinion on this logic though
https://github.com/llvm/llvm-project/pull/223124
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits