| 1 |
// RUN: %clang_cc1 %s -verify -fsyntax-only |
| 2 |
// RUN: %clang_cc1 %s -std=c++03 -Wno-c++11-extensions -verify -fsyntax-only |
| 3 |
|
| 4 |
namespace test1 { |
| 5 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) class A; // expected-warning{{attribute 'visibility' is ignored, place it after "class" to apply attribute to type declaration}} \ |
| 6 |
// expected-warning{{attribute 'aligned' is ignored, place it after "class" to apply attribute to type declaration}} |
| 7 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) struct B; // expected-warning{{attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration}} \ |
| 8 |
// expected-warning{{attribute 'aligned' is ignored, place it after "struct" to apply attribute to type declaration}} |
| 9 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) union C; // expected-warning{{attribute 'visibility' is ignored, place it after "union" to apply attribute to type declaration}} \ |
| 10 |
// expected-warning{{attribute 'aligned' is ignored, place it after "union" to apply attribute to type declaration}} |
| 11 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum D {D}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum" to apply attribute to type declaration}} \ |
| 12 |
// expected-warning{{attribute 'aligned' is ignored, place it after "enum" to apply attribute to type declaration}} |
| 13 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum class EC {}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum class" to apply attribute to type declaration}} \ |
| 14 |
// expected-warning{{attribute 'aligned' is ignored, place it after "enum class" to apply attribute to type declaration}} |
| 15 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum struct ES {}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum struct" to apply attribute to type declaration}} \ |
| 16 |
// expected-warning{{attribute 'aligned' is ignored, place it after "enum struct" to apply attribute to type declaration}} |
| 17 |
|
| 18 |
// Test that we get the same warnings for type declarations nested in a record. |
| 19 |
struct X { |
| 20 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) class A; // expected-warning{{attribute 'visibility' is ignored, place it after "class" to apply attribute to type declaration}} \ |
| 21 |
// expected-warning{{attribute 'aligned' is ignored, place it after "class" to apply attribute to type declaration}} |
| 22 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) struct B; // expected-warning{{attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration}} \ |
| 23 |
// expected-warning{{attribute 'aligned' is ignored, place it after "struct" to apply attribute to type declaration}} |
| 24 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) union C; // expected-warning{{attribute 'visibility' is ignored, place it after "union" to apply attribute to type declaration}} \ |
| 25 |
// expected-warning{{attribute 'aligned' is ignored, place it after "union" to apply attribute to type declaration}} |
| 26 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum D {D}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum" to apply attribute to type declaration}} \ |
| 27 |
// expected-warning{{attribute 'aligned' is ignored, place it after "enum" to apply attribute to type declaration}} |
| 28 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum class EC {}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum class" to apply attribute to type declaration}} \ |
| 29 |
// expected-warning{{attribute 'aligned' is ignored, place it after "enum class" to apply attribute to type declaration}} |
| 30 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum struct ES {}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum struct" to apply attribute to type declaration}} \ |
| 31 |
// expected-warning{{attribute 'aligned' is ignored, place it after "enum struct" to apply attribute to type declaration}} |
| 32 |
|
| 33 |
// Also test [[]] attribute syntax. (On a non-nested declaration, these |
| 34 |
// generate a hard "misplaced attributes" error, which we test for |
| 35 |
// elsewhere.) |
| 36 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] class E; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "class" to apply attribute to type declaration}} \ |
| 37 |
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "class" to apply attribute to type declaration}} |
| 38 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] struct F; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "struct" to apply attribute to type declaration}} \ |
| 39 |
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "struct" to apply attribute to type declaration}} |
| 40 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] union G; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "union" to apply attribute to type declaration}} \ |
| 41 |
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "union" to apply attribute to type declaration}} |
| 42 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum H {H}; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "enum" to apply attribute to type declaration}} \ |
| 43 |
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "enum" to apply attribute to type declaration}} |
| 44 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum class I {}; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "enum class" to apply attribute to type declaration}} \ |
| 45 |
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "enum class" to apply attribute to type declaration}} |
| 46 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum struct J {}; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "enum struct" to apply attribute to type declaration}} \ |
| 47 |
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "enum struct" to apply attribute to type declaration}} |
| 48 |
}; |
| 49 |
} |
| 50 |
|
| 51 |
namespace test2 { |
| 52 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) class A {} a; |
| 53 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) struct B {} b; |
| 54 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) union C {} c; |
| 55 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum D {D} d; |
| 56 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum class EC {} ec; |
| 57 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum struct ES {} es; |
| 58 |
|
| 59 |
struct X { |
| 60 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) class A {} a; |
| 61 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) struct B {} b; |
| 62 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) union C {} c; |
| 63 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum D {D} d; |
| 64 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum class EC {} ec; |
| 65 |
__attribute__((visibility("hidden"))) __attribute__((aligned)) enum struct ES {} es; |
| 66 |
|
| 67 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] class E {} e; |
| 68 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] struct F {} f; |
| 69 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] union G {} g; |
| 70 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum H {H} h; |
| 71 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum class I {} i; |
| 72 |
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum struct J {} j; |
| 73 |
}; |
| 74 |
} |