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