[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
================
@@ -8,4 +8,4 @@ extern __declspec(selectany) const int x1 = 1; // no warning, const means we nee
// Should we really warn on this?
extern __declspec(selectany) int x2 = 1; // expected-warning {{'extern' variable has an initializer}}
-__declspec(selectany) void foo(void) { } // expected-error{{'selectany' can only be applied to data items with external linkage}}
+__declspec(selectany) void foo(void) { } // expected-error{{'selectany' attribute only applies to global variables}}
----------------
AaronBallman wrote:
Based on Microsoft's feedback, the original diagnostic text was a bit better; it will apply to local variables with an `extern` storage class: https://godbolt.org/z/cn7axzoeY
https://github.com/llvm/llvm-project/pull/189641
More information about the cfe-commits
mailing list