[clang] [clang] Diagnose when spelled 'abi_tag' on namespace doesn't match applied one. (PR #221039)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 30 08:54:25 PDT 2026


================
@@ -12106,9 +12106,10 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
   AddPragmaAttributes(DeclRegionScope, Namespc);
   ProcessAPINotes(Namespc);
 
-  // FIXME: Should we be merging attributes?
   if (const VisibilityAttr *Attr = Namespc->getAttr<VisibilityAttr>())
     PushNamespaceVisibilityAttr(Attr, Loc);
+  if (PrevNS)
+    mergeDeclAttributes(Namespc, PrevNS);
----------------
AaronBallman wrote:

> Thanks for pointing it out, need to check it more carefully. Based on the lack of namespaces in `SubjectList` I've decided attributes aren't usually applied to namespaces.

abi_tag, gsl::suppress, and type_visibility are the only ones; it's not a common subject for attributes and whether to inherit on reopening or not is likely a per-attribute decision.

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


More information about the cfe-commits mailing list