summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/declspec-selectany.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCXX/declspec-selectany.cpp')
-rw-r--r--clang/test/SemaCXX/declspec-selectany.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/declspec-selectany.cpp b/clang/test/SemaCXX/declspec-selectany.cpp
new file mode 100644
index 00000000000..7e64a2924c9
--- /dev/null
+++ b/clang/test/SemaCXX/declspec-selectany.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-windows-msvc -fdeclspec -verify
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-windows-msvc -fdeclspec -verify
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-scei-ps4 -fdeclspec -verify
+
+// MSVC emits this error too.
+const int __declspec(selectany) test1 = 0; // expected-error {{'selectany' can only be applied to data items with external linkage}}
+
+extern const int test2;
+const int test2 = 42; // expected-note {{previous definition is here}}
+extern __declspec(selectany) const int test2; // expected-warning {{attribute declaration must precede definition}}
+
+extern const int test3;
+const int __declspec(selectany) test3 = 42; // Standard usage.
+
+struct Test4 {
+ static constexpr int sdm = 0;
+};
+__declspec(selectany) constexpr int Test4::sdm; // no warning
OpenPOWER on IntegriCloud