]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/Warray-parameter-3.c
1 /* PR c/50584 - No warning for passing small array to C99 static array
4 { dg-options "-Wall -Warray-parameter=1" } */
6 /* Verify that at level 1 mismatches in the bounds of ordinary array
7 parameters don't trigger -Warray-parameter. */
14 /* Same as above but starting with an array with a specified bound. */
21 /* Same for multidimensional arrays. */
22 void fax_y (int[][3]);
23 void fax_y (int[0][3]);
24 void fax_y (int[1][3]);
25 void fax_y (int[2][3]);
26 void fax_y (int[3][3]);
28 /* Same as above but starting with an array with a specified bound. */
29 void gax_y (int[3][5]);
30 void gax_y (int[2][5]);
31 void gax_y (int[1][5]);
32 void gax_y (int[0][5]);
33 void gax_y (int[][5]);
35 /* Exercise VLAs with a mismatch in the bound for an ordinary array. */
36 void fvlax_y (int n
, int[][n
]);
37 void fvlax_y (int n
, int[0][n
]);
38 void fvlax_y (int n
, int[1][n
]);
39 void fvlax_y (int n
, int[2][n
]);
40 void fvlax_y (int n
, int[3][n
]);
42 void fvlaxn_y (int n
, int[][n
]);
43 void fvlaxn_y (int n
, int[0][n
]);
44 void fvlaxn_y (int n
, int[1][n
]);
45 void fvlaxn_y (int n
, int[2][n
]);
46 void fvlaxn_y (int n
, int[3][n
]);
48 void fvlaxx_y (int[][*]);
49 void fvlaxx_y (int[0][*]);
50 void fvlaxx_y (int[1][*]);
51 void fvlaxx_y (int[2][*]);
52 void fvlaxx_y (int[3][*]);
54 /* Verify that mismatches in the bounds of array parameters declared
55 static do trigger -Warray-parameter. */
56 void fas1 (int[static 1]); // { dg-message "previously declared as 'int\\\[static 1]'" }
57 void fas1 (int[static 2]); // { dg-warning "\\\[-Warray-parameter=" }
60 /* Also verify that -Warray-bounds doesn't trigger for ordinary array
62 #pragma GCC optimize ("2")
64 __attribute__ ((noipa
)) void
67 a
[0] = 0; a
[1] = 1; a
[2] = 2; a
[3] = 3;
70 __attribute__ ((noipa
)) void
73 a
[0] = 0; a
[1] = 1; a
[2] = 2; a
[3] = 3;
76 /* ...but does for static arrays. */
77 __attribute__ ((noipa
)) void
78 gcas3 (char a
[static 3])
80 a
[0] = 0; a
[1] = 1; a
[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v4qi_store_unalign } } }
81 a
[3] = 3; // { dg-warning "\\\[-Warray-bounds" }
84 __attribute__ ((noipa
)) void
85 gias3 (int a
[static 3])
87 a
[0] = 0; a
[1] = 1; a
[2] = 2;
88 a
[3] = 3; // { dg-warning "\\\[-Warray-bounds" }