diff options
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 885e8759422..50951a03f0c 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4636,6 +4636,15 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { ND.dropAttr<WeakRefAttr>(); } } + + // 'selectany' only applies to externally visible varable 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>(); + } + } } /// Given that we are within the definition of the given function, |