[clang] [Clang] Avoid assertion failure for initialized extern aliases (PR #223124)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 24 06:04:51 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:
I have a question I'd like to ask about the following case:
```cpp
int v1;
struct S {
static int i __attribute__((alias("v1")));
};
int S::i = 12;
```
Should
```static int i __attribute__((alias("v1")));```
be considered a definition or merely a declaration here?
According to the standard C++ rules, an in-class declaration of a non-inline static data member is normally not a definition.
However, under the semantics of the alias extension, the alias declaration itself appears to define the corresponding symbol.
So I'm a little unsure how this declaration should be classified in this case.
https://github.com/llvm/llvm-project/pull/223124
More information about the cfe-commits
mailing list