]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/c2x-attr-syntax-2.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / c2x-attr-syntax-2.c
CommitLineData
4e03c3a7
JM
1/* Test C2x attribute syntax. Test ignored attributes diagnosed. */
2/* { dg-do compile } */
3/* { dg-options "-std=c2x -pedantic-errors" } */
4
5/* A GNU attribute that is valid in some contexts, but should be
6 diagnosed in contexts where all attributes are ignored (attribute
7 declarations, except for fallthrough attributes, and
8 statements). */
9#define CTX [[gnu::const]]
10
11/* An attribute that is unknown, so ignored with a warning. */
12#define UNK [[gnu::no_such_attribute(![!(!)!]!,;;)]]
13
14CTX; /* { dg-warning "ignored" } */
15UNK; /* { dg-warning "ignored" } */
16
17UNK extern int a; /* { dg-warning "ignored" } */
18extern int UNK a; /* { dg-warning "ignored" } */
19extern int a UNK; /* { dg-warning "ignored" } */
20
21int f () UNK; /* { dg-warning "ignored" } */
22int f (void) UNK; /* { dg-warning "ignored" } */
23int g (UNK int a); /* { dg-warning "ignored" } */
24int g (int UNK a); /* { dg-warning "ignored" } */
25int g (int a UNK); /* { dg-warning "ignored" } */
26int g (UNK int); /* { dg-warning "ignored" } */
27int g (int UNK); /* { dg-warning "ignored" } */
28int g (int) UNK; /* { dg-warning "ignored" } */
29
30int *UNK p; /* { dg-warning "ignored" } */
31int b[3] UNK; /* { dg-warning "ignored" } */
32
33int h (int () UNK); /* { dg-warning "ignored" } */
34
35struct UNK s; /* { dg-warning "ignored" } */
36union UNK u; /* { dg-warning "ignored" } */
37
38struct UNK s2 { int a; }; /* { dg-warning "ignored" } */
39union UNK u2 { int a; }; /* { dg-warning "ignored" } */
40
41struct s3 { UNK int a; }; /* { dg-warning "ignored" } */
42struct s4 { int UNK a; }; /* { dg-warning "ignored" } */
43union u3 { UNK int a; }; /* { dg-warning "ignored" } */
44union u4 { int UNK a; }; /* { dg-warning "ignored" } */
45
46int z = sizeof (int UNK); /* { dg-warning "ignored" } */
47
48enum UNK { E1 }; /* { dg-warning "ignored" } */
49enum { E2 UNK }; /* { dg-warning "ignored" } */
50enum { E3 UNK = 4 }; /* { dg-warning "ignored" } */
51
52void
53func (void) UNK { /* { dg-warning "ignored" } */
54 UNK int var; /* { dg-warning "ignored" } */
55 CTX { } /* { dg-warning "ignored" } */
56 CTX; /* { dg-warning "ignored" } */
57 CTX var = 1; /* { dg-warning "ignored" } */
58 CTX x: var = 2; /* { dg-warning "ignored" } */
59 for (UNK int zz = 1; zz < 10; zz++) ; /* { dg-warning "ignored" } */
60}