]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/c2x-attr-syntax-3.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / c2x-attr-syntax-3.c
CommitLineData
4e03c3a7
JM
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
11void
12f1 (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
21void
22f2 (void)
23{
24 [[]] _Static_assert (1); /* { dg-error "expected" } */
25}
26
27/* Declarations, including attribute declarations, cannot appear after
8b7a9a24 28 labels when a statement is expected. */
4e03c3a7
JM
29
30void
31f3 (void)
32{
8b7a9a24
MU
33 if (1)
34 x: [[]]; /* { dg-error "expected" } */
35}
4e03c3a7
JM
36
37/* Prefix attributes cannot appear on type names. */
38
39int 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
45const struct [[]] s2; /* { dg-warning "useless type qualifier" } */
46/* { dg-error "invalid use of attributes in empty declaration" "invalid" { target *-*-* } .-1 } */
47
48const union [[]] u2; /* { dg-warning "useless type qualifier" } */
49/* { dg-error "invalid use of attributes in empty declaration" "invalid" { target *-*-* } .-1 } */
50
51struct [[]] s3 *sv; /* { dg-error "expected" } */
52
53union [[]] u3 *uv; /* { dg-error "expected" } */
54
55enum e { E1 };
56
57enum [[]] e *ev; /* { dg-error "expected" } */