================
@@ -8907,6 +8907,20 @@ void Sema::ProcessDeclAttributes(Scope *S, Decl *D,
const Declarator &PD) {
// Look for API notes that map to attributes.
ProcessAPINotes(D);
+
+ // An initializer makes a variable declaration incompatible with an alias
+ // attribute. Attributes are processed before the initializer is attached to
+ // the VarDecl, so an extern variable with an initializer still appears to be
+ // a declaration in handleAliasAttr(). Use the information recorded by the
+ // parser and do not let the AliasAttr escape attribute processing.
+ if (auto *VD = dyn_cast<VarDecl>(D)) {
----------------
AaronBallman wrote:
This is definitely not the right way to solve this -- `ProcessDeclAttributes()`
should be a general function. Per-attribute logic should not be implemented
here. Usually, this would be done from `handleAliasAttr()`, except that doesn't
have access to `PD` and we should not thread that through (again, because
attributes should be generalized). So I think this should probably be handled
when attaching the initializer to the declaration, with a comment explaining
why it's happening there.
https://github.com/llvm/llvm-project/pull/223124
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits