[clang] [Clang] disallow selectany on non-global-variable declarations (PR #189641)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 29 04:27:53 PDT 2026
================
@@ -4477,6 +4477,7 @@ def DLLImportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetHasDLLImpor
def SelectAny : InheritableAttr {
let Spellings = [Declspec<"selectany">, GCC<"selectany">];
+ let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
----------------
AaronBallman wrote:
I would expect changes in SemaDeclAttr.cpp to remove the use of `err_attribute_selectany_non_extern_data` from `checkSelectAnyAttr()`, but I am curious why `isExternallyVisible()` was insufficient there. Regardless, I think this needs a different subject because local static variables cannot be `selectany`: https://github.com/llvm/llvm-project/blob/6446435534746effdb2bedf6127bdf996f9fd3f0/clang/include/clang/AST/Decl.h#L1237
https://github.com/llvm/llvm-project/pull/189641
More information about the cfe-commits
mailing list