1 /* PR c/50584 - No warning for passing small array to C99 static array
2    declarator
3 
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
7    asks for.
8 
9    { dg-do compile }
10    { dg-options "-O2 -Wall -Warray-parameter -Wno-vla-parameter" } */
11 
12 #define NOIPA __attribute__  ((noipa))
13 
14 void sink (void*, ...);
15 
16 #define T(...) sink (0, __VA_ARGS__)
17 
18 
fca1(char a[1])19 NOIPA void fca1 (char a[1])
20 {
21   T (a[0]);
22   T (a[1]);                   // { dg-warning "-Warray-bounds" }
23 }
24 
fcas1(char a[static1])25 NOIPA void fcas1 (char a[static 1])
26 {
27   T (a[0]);
28   T (a[1]);                   // { dg-warning "-Warray-bounds" }
29 }
30 
fca2(char a[2])31 NOIPA void fca2 (char a[2])
32 {
33   T (a[0]); T (a[1]);
34   T (a[2]);                   // { dg-warning "-Warray-bounds" }
35 }
36 
fcas2(char a[static2])37 NOIPA void fcas2 (char a[static 2])
38 {
39   T (a[0]); T (a[1]);
40   T (a[2]);                   // { dg-warning "-Warray-bounds" }
41 }
42 
fca3(char a[3])43 NOIPA void fca3 (char a[3])
44 {
45   T (a[0]); T (a[1]); T (a[2]);
46   T (a[3]);                   // { dg-warning "-Warray-bounds" }
47 }
48 
fcas3(char a[static3])49 NOIPA void fcas3 (char a[static 3])
50 {
51   T (a[0]); T (a[1]); T (a[2]);
52   T (a[3]);                   // { dg-warning "-Warray-bounds" }
53 }
54 
55 
fca1_1(char a[1][1])56 NOIPA void fca1_1 (char a[1][1])
57 {
58   T (a[0][0]);
59   T (a[0][1]);                // { dg-warning "-Warray-bounds" }
60 }
61