Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / c23-attr-syntax-2.c
blob36b6fc2577978de9b53ebf24015c67e96d40a642
1 /* Test C23 attribute syntax. Test ignored attributes diagnosed. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c23 -pedantic-errors" } */
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]]
11 /* An attribute that is unknown, so ignored with a warning. */
12 #define UNK [[gnu::no_such_attribute(![!(!)!]!,;;)]]
14 CTX; /* { dg-warning "ignored" } */
15 UNK; /* { dg-warning "ignored" } */
17 UNK extern int a; /* { dg-warning "ignored" } */
18 extern int UNK a; /* { dg-warning "ignored" } */
19 extern int a UNK; /* { dg-warning "ignored" } */
21 int f () UNK; /* { dg-warning "ignored" } */
22 int f (void) UNK; /* { dg-warning "ignored" } */
23 int g (UNK int a); /* { dg-warning "ignored" } */
24 int g (int UNK a); /* { dg-warning "ignored" } */
25 int g (int a UNK); /* { dg-warning "ignored" } */
26 int g (UNK int); /* { dg-warning "ignored" } */
27 int g (int UNK); /* { dg-warning "ignored" } */
28 int g (int) UNK; /* { dg-warning "ignored" } */
30 int *UNK p; /* { dg-warning "ignored" } */
31 int b[3] UNK; /* { dg-warning "ignored" } */
33 int h (int () UNK); /* { dg-warning "ignored" } */
35 struct UNK s; /* { dg-warning "ignored" } */
36 union UNK u; /* { dg-warning "ignored" } */
38 struct UNK s2 { int a; }; /* { dg-warning "ignored" } */
39 union UNK u2 { int a; }; /* { dg-warning "ignored" } */
41 struct s3 { UNK int a; }; /* { dg-warning "ignored" } */
42 struct s4 { int UNK a; }; /* { dg-warning "ignored" } */
43 union u3 { UNK int a; }; /* { dg-warning "ignored" } */
44 union u4 { int UNK a; }; /* { dg-warning "ignored" } */
46 int z = sizeof (int UNK); /* { dg-warning "ignored" } */
48 enum UNK { E1 }; /* { dg-warning "ignored" } */
49 enum { E2 UNK }; /* { dg-warning "ignored" } */
50 enum { E3 UNK = 4 }; /* { dg-warning "ignored" } */
52 void
53 func (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" } */