[clang] [Clang] disallow selectany on non-global-variable declarations (PR #189641)
Oleksandr Tarasiuk via cfe-commits
cfe-commits at lists.llvm.org
Wed May 6 09:44:32 PDT 2026
================
@@ -7146,15 +7148,17 @@ static void checkAliasAttr(Sema &S, NamedDecl &ND) {
}
static void checkSelectAnyAttr(Sema &S, NamedDecl &ND) {
- // 'selectany' only applies to externally visible variable declarations.
- // It does not apply to functions.
- if (SelectAnyAttr *Attr = ND.getAttr<SelectAnyAttr>()) {
- if (isa<FunctionDecl>(ND) || !ND.isExternallyVisible()) {
- S.Diag(Attr->getLocation(),
- diag::err_attribute_selectany_non_extern_data);
- ND.dropAttr<SelectAnyAttr>();
- }
+ SelectAnyAttr *Attr = ND.getAttr<SelectAnyAttr>();
+ if (!Attr)
----------------
a-tarasyuk wrote:
@erichkeane, I think isExternallyVisible should already cover `selectany` cases - unless we need to be more precise here?
https://github.com/llvm/llvm-project/pull/189641
More information about the cfe-commits
mailing list