1 /* Test C2x attribute syntax. Invalid uses of attributes. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c2x -pedantic-errors" } */
5 /* Prefix attributes not allowed on declarations without declarators. */
7 [[]] struct s
{ int a
; }; /* { dg-error "empty declaration" } */
9 [[]] union u
{ int a
; }; /* { dg-error "empty declaration" } */
14 [[]] struct t
{ int a
; }; /* { dg-error "empty declaration" } */
17 /* Prefix attributes not allowed on _Static_assert. */
19 [[]] _Static_assert (1); /* { dg-error "expected" } */
24 [[]] _Static_assert (1); /* { dg-error "expected" } */
27 /* Declarations, including attribute declarations, cannot appear after
28 labels when a statement is expected. */
34 x
: [[]]; /* { dg-error "expected" } */
37 /* Prefix attributes cannot appear on type names. */
39 int z
= sizeof ([[]] int); /* { dg-error "expected" } */
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;". */
45 const struct [[]] s2
; /* { dg-warning "useless type qualifier" } */
46 /* { dg-error "invalid use of attributes in empty declaration" "invalid" { target *-*-* } .-1 } */
48 const union [[]] u2
; /* { dg-warning "useless type qualifier" } */
49 /* { dg-error "invalid use of attributes in empty declaration" "invalid" { target *-*-* } .-1 } */
51 struct [[]] s3
*sv
; /* { dg-error "expected" } */
53 union [[]] u3
*uv
; /* { dg-error "expected" } */
57 enum [[]] e
*ev
; /* { dg-error "expected" } */