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

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 4 21:25:01 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(),
----------------
efriedma-quic wrote:

What's the relationship between Prev and ND?

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


More information about the cfe-commits mailing list