]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/Warray-bounds-64.c
1 /* PR c/50584 - No warning for passing small array to C99 static array
4 Verify that out-of-bounds accesses to array arguments are diagnosed,
5 both to ordinary array parameters with constant bounds and to array
6 parameters declared static. This is the converse of what PR 50584
10 { dg-options "-O2 -Wall -Warray-parameter -Wno-vla-parameter" } */
12 #define NOIPA __attribute__ ((noipa))
14 void sink (void*, ...);
16 #define T(...) sink (0, __VA_ARGS__)
19 NOIPA
void fca1 (char a
[1])
22 T (a
[1]); // { dg-warning "-Warray-bounds" }
25 NOIPA
void fcas1 (char a
[static 1])
28 T (a
[1]); // { dg-warning "-Warray-bounds" }
31 NOIPA
void fca2 (char a
[2])
34 T (a
[2]); // { dg-warning "-Warray-bounds" }
37 NOIPA
void fcas2 (char a
[static 2])
40 T (a
[2]); // { dg-warning "-Warray-bounds" }
43 NOIPA
void fca3 (char a
[3])
45 T (a
[0]); T (a
[1]); T (a
[2]);
46 T (a
[3]); // { dg-warning "-Warray-bounds" }
49 NOIPA
void fcas3 (char a
[static 3])
51 T (a
[0]); T (a
[1]); T (a
[2]);
52 T (a
[3]); // { dg-warning "-Warray-bounds" }
56 NOIPA
void fca1_1 (char a
[1][1])
59 T (a
[0][1]); // { dg-warning "-Warray-bounds" }