Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-parameter-4.c
blobb702d730a13ec7a7114285e242f95d78fdb9d001
1 /* PR c/50584 - No warning for passing small array to C99 static array
2 declarator
3 Verify warnings for multidimensional arrays, including mismatches
4 in bounds of arrays of VLAs. (Mismatches in variable bounds are
5 diagnosed by -Wvla-parameter.)
6 { dg-do compile }
7 { dg-options "-Wall -Warray-parameter=2" } */
9 // Verify that equivalent forms don't tigger a warning.
11 typedef int IA1[1];
12 typedef int IA1x_[][1];
13 typedef int IA1x0[0][1];
15 void fia_x1 (int[][1]);
16 void fia_x1 (IA1[0]);
17 void fia_x1 (IA1x_);
18 void fia_x1 (IA1x0);
19 void fia_x1 (int[0][1]);
20 void fia_x1 (int[static 0][1]);
22 // Same as above one more time.
23 void fia_x1 (int[][1]);
24 void fia_x1 (IA1[0]);
25 void fia_x1 (IA1x_);
26 void fia_x1 (IA1x0);
27 void fia_x1 (int[0][1]);
28 void fia_x1 (int[static 0][1]);
31 void fia1x1 (int[1][1]);
32 void fia1x1 (int[1][1]);
33 void fia1x1 (int[static 1][1]);
35 void fia2x1 (int[2][1]);
36 void fia2x1 (int[2][1]);
37 void fia2x1 (int[static 2][1]);
39 void fia1x2 (int[1][2]);
40 void fia1x2 (int[1][2]);
41 void fia1x2 (int[static 1][2]);
43 void fia1x1_2x1 (int[1][1]); // { dg-message "previously declared as 'int\\\[1]\\\[1]'" }
44 void fia1x1_2x1 (int[2][1]); // { dg-warning "\\\[-Warray-parameter" }
45 void fia1x1_2x1 (int[static 1][1]);
46 void fia1x1_2x1 (int[static 2][1]); // { dg-warning "\\\[-Warray-parameter" }
49 void fia2x1_1x1 (int[2][1]); // { dg-message "previously declared as 'int\\\[2]\\\[1]'" }
50 void fia2x1_1x1 (int[1][1]); // { dg-warning "\\\[-Warray-parameter" }
51 void fia2x1_1x1 (int[2][1]);
52 void fia2x1_1x1 (int[static 1][1]); // { dg-warning "\\\[-Warray-parameter" }
53 void fia2x1_1x1 (int[static 2][1]);
56 extern int n1, n2;
58 void fca_xn1 (char[][n1]);
59 void fca_xn1 (char[0][n1]);
60 void fca_xn1 (char[static 0][n1]);
62 void fca1xn1_2xn1 (char[1][n1]);
63 void fca1xn1_2xn1 (char[2][n1]); // { dg-warning "\\\[-Warray-parameter" }
64 void fca1xn1_2xn1 (char[1][n1]);
65 void fca1xn1_2xn1 (char[static 1][n1]);
66 void fca1xn1_2xn1 (char[static 2][n1]); // { dg-warning "\\\[-Warray-parameter" }
69 /* Exercise VLAs with a mismatch in the bound for an ordinary array. */
70 void fvlax_y (int n, int[][n]);
71 void fvlax_y (int n, int[0][n]);
72 void fvlax_y (int n, int[1][n]); // { dg-warning "argument 2 of type 'int\\\[1]\\\[n]' with mismatched bound" }
73 void fvlax_y (int n, int[2][n]); // { dg-warning "argument 2 of type 'int\\\[2]\\\[n]' with mismatched bound" }
74 void fvlax_y (int n, int[3][n]); // { dg-warning "argument 2 of type 'int\\\[3]\\\[n]' with mismatched bound" }
76 void fvlaxn_y (int n, int[][n]);
77 void fvlaxn_y (int n, int[0][n]);
78 void fvlaxn_y (int n, int[1][n]); // { dg-warning "\\\[-Warray-parameter" }
79 void fvlaxn_y (int n, int[2][n]); // { dg-warning "\\\[-Warray-parameter" }
80 void fvlaxn_y (int n, int[3][n]); // { dg-warning "\\\[-Warray-parameter" }
82 void fvlaxx_y (int[][*]);
83 void fvlaxx_y (int[0][*]);
84 void fvlaxx_y (int[1][*]); // { dg-warning "\\\[-Warray-parameter" }
85 void fvlaxx_y (int[2][*]); // { dg-warning "\\\[-Warray-parameter" }
86 void fvlaxx_y (int[3][*]); // { dg-warning "\\\[-Warray-parameter" }
89 // Verify an array of pointers to an array of function pointers.
91 void ffpa7_5 (void (* (* (* [7])[5])(void))(void));
92 // { dg-message "previously declared as 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[7]\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "note" { target *-*-* } .-1 }
93 void ffpa7_5 (void (* (* (* [6])[5])(void))(void));
94 // { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[6]\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 }
95 void ffpa7_5 (void (* (* (* [])[5])(void))(void));
96 // { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[]\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 }
97 void ffpa7_5 (void (* (* (* (*))[5])(void))(void));
98 // { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\*\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)' declared as a pointer" "" { target *-*-* } .-1 }
100 // Same as above but with array of pointers to a VLA of function pointers.
101 void ffpa7_n1 (void (* (* (* [7])[n1])(void))(void));
102 // { dg-message "previously declared as 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[7]\\\)\\\[n1]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "note" { target *-*-* } .-1 }
103 void ffpa7_n1 (void (* (* (* [8])[n1])(void))(void));
104 // { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[8]\\\)\\\[n1]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 }
106 void ffpa9_x (void (* (* (* [9])[*])(void))(void));
107 // { dg-message "previously declared as 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[9]\\\)\\\[\\\*]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "pr?????" { xfail *-*-* } .-1 }
108 // { dg-message "previously declared as 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[9]\\\)\\\[0]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "" { target *-*-* } .-2 }
109 void ffpa9_x (void (* (* (* [8])[*])(void))(void));
110 // { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[8]\\\)\\\[\\\*]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "pr?????" { xfail *-*-* } .-1 }
111 // { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[8]\\\)\\\[0]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-2 }
113 /* Verify a three-dimensional array of pointers to two-dimensional arrays
114 of pointers to function pointers. */
116 void ffpa7_5_3 (void (* (* (* (* [7])[5])[3])(void))(void));
117 // { dg-message "previously declared as 'void ?\\\(\\\* ?\\\(\\\* ?\\\(\\\* ?\\\(\\\* ?\\\[7]\\\)\\\[5]\\\)\\\[3]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "note" { target *-*-* } .-1 }
118 void ffpa7_5_3 (void (* (* (* (* [1])[5])[3])(void))(void));
119 // { dg-warning "argument 1 of type 'void ?\\\(\\\* ?\\\(\\\* ?\\\(\\\* ?\\\(\\\* ?\\\[1]\\\)\\\[5]\\\)\\\[3]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 }