1 /* Test C2x attribute syntax.  Invalid uses of attributes.  */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c2x -pedantic-errors" } */
4 
5 /* Prefix attributes not allowed on declarations without declarators.  */
6 
7 [[]] struct s { int a; }; /* { dg-error "empty declaration" } */
8 
9 [[]] union u { int a; }; /* { dg-error "empty declaration" } */
10 
11 void
f1(void)12 f1 (void)
13 {
14   [[]] struct t { int a; }; /* { dg-error "empty declaration" } */
15 }
16 
17 /* Prefix attributes not allowed on _Static_assert.  */
18 
19 [[]] _Static_assert (1); /* { dg-error "expected" } */
20 
21 void
f2(void)22 f2 (void)
23 {
24   [[]] _Static_assert (1); /* { dg-error "expected" } */
25 }
26 
27 /* Declarations, including attribute declarations, cannot appear after
28    labels when a statement is expected.  */
29 
30 void
f3(void)31 f3 (void)
32 {
33   if (1)
34     x: [[]]; /* { dg-error "expected" } */
35 }
36 
37 /* Prefix attributes cannot appear on type names.  */
38 
39 int z = sizeof ([[]] int); /* { dg-error "expected" } */
40 
41 /* Attributes are not allowed after struct, union or enum, except when
42    the type contents are being defined or the declaration is just
43    "struct-or-union atribute-specifier-sequence identifier;".  */
44 
45 const struct [[]] s2; /* { dg-warning "useless type qualifier" } */
46 /* { dg-error "invalid use of attributes in empty declaration" "invalid" { target *-*-* } .-1 } */
47 
48 const union [[]] u2; /* { dg-warning "useless type qualifier" } */
49 /* { dg-error "invalid use of attributes in empty declaration" "invalid" { target *-*-* } .-1 } */
50 
51 struct [[]] s3 *sv; /* { dg-error "expected" } */
52 
53 union [[]] u3 *uv; /* { dg-error "expected" } */
54 
55 enum e { E1 };
56 
57 enum [[]] e *ev; /* { dg-error "expected" } */
58