Debian Codegraph @

gcc/testsuite/gcc.dg/strict-flex-array-1.c

raw
1 /* testing the correct usage of attribute strict_flex_array. */
2 /* { dg-do compile } */
3 /* { dg-options "-O2" } */
4
5
6 int x __attribute__ ((strict_flex_array (1))); /* { dg-error "'strict_flex_array' attribute may not be specified for 'x'" } */
7
8 int [[gnu::strict_flex_array(1)]] x; /* { dg-warning "'strict_flex_array' attribute does not apply to types" } */
9
10 struct trailing {
11 int a;
12 int c __attribute ((strict_flex_array)); /* { dg-error "wrong number of arguments specified for 'strict_flex_array' attribute" } */
13 };
14
15 struct trailing_1 {
16 int a;
17 int b;
18 int c __attribute ((strict_flex_array (2))); /* { dg-error "'strict_flex_array' attribute may not be specified for a non-array field" } */
19 };
20
21 extern int d;
22
23 struct trailing_array_2 {
24 int a;
25 int b;
26 int c[1] __attribute ((strict_flex_array (d))); /* { dg-error "'strict_flex_array' attribute argument not an integer" } */
27 };
28
29 struct trailing_array_3 {
30 int a;
31 int b;
32 int c[0] __attribute ((strict_flex_array (5))); /* { dg-error "'strict_flex_array' attribute argument '5' is not an integer constant between 0 and 3" } */
33 };