Reid Kleckner | b00a49d | 2019-09-12 17:55:48 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++14 %s -triple x86_64-windows-msvc -fdeclspec -verify |
| 2 | // RUN: %clang_cc1 -std=c++17 %s -triple x86_64-windows-msvc -fdeclspec -verify |
| 3 | // RUN: %clang_cc1 -std=c++14 %s -triple x86_64-scei-ps4 -fdeclspec -verify |
| 4 | |
| 5 | // MSVC emits this error too. |
| 6 | const int __declspec(selectany) test1 = 0; // expected-error {{'selectany' can only be applied to data items with external linkage}} |
| 7 | |
| 8 | extern const int test2; |
| 9 | const int test2 = 42; // expected-note {{previous definition is here}} |
| 10 | extern __declspec(selectany) const int test2; // expected-warning {{attribute declaration must precede definition}} |
| 11 | |
| 12 | extern const int test3; |
| 13 | const int __declspec(selectany) test3 = 42; // Standard usage. |
| 14 | |
| 15 | struct Test4 { |
| 16 | static constexpr int sdm = 0; |
| 17 | }; |
| 18 | __declspec(selectany) constexpr int Test4::sdm; // no warning |