[clang] [Clang][Sema] Accept weak reference after declaration (PR #228809)

via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 4 21:42:43 PDT 2026


================
@@ -8804,6 +8804,31 @@ NamedDecl *Sema::DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II,
 void Sema::DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W) {
   if (W.getAlias()) { // clone decl, impersonate __attribute(weak,alias(...))
     IdentifierInfo *NDId = ND->getIdentifier();
+
+    // Append attribute on previous declaration only.
+    NamedDecl *Prev = LookupSingleName(TUScope, W.getAlias(), W.getLocation(),
----------------
aokblast wrote:

```
void test1();
#pragma test1 = test2;
```

Prev = void test1();
ND = test2; This means we want to attach alias attributes to the Prev while the NDId is from test2.

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


More information about the cfe-commits mailing list