]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/Warray-parameter-4.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / Warray-parameter-4.c
CommitLineData
6450f073
MS
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" } */
8
9// Verify that equivalent forms don't tigger a warning.
10
11typedef int IA1[1];
12typedef int IA1x_[][1];
13typedef int IA1x0[0][1];
14
15void fia_x1 (int[][1]);
16void fia_x1 (IA1[0]);
17void fia_x1 (IA1x_);
18void fia_x1 (IA1x0);
19void fia_x1 (int[0][1]);
20void fia_x1 (int[static 0][1]);
21
22// Same as above one more time.
23void fia_x1 (int[][1]);
24void fia_x1 (IA1[0]);
25void fia_x1 (IA1x_);
26void fia_x1 (IA1x0);
27void fia_x1 (int[0][1]);
28void fia_x1 (int[static 0][1]);
29
30
31void fia1x1 (int[1][1]);
32void fia1x1 (int[1][1]);
33void fia1x1 (int[static 1][1]);
34
35void fia2x1 (int[2][1]);
36void fia2x1 (int[2][1]);
37void fia2x1 (int[static 2][1]);
38
39void fia1x2 (int[1][2]);
40void fia1x2 (int[1][2]);
41void fia1x2 (int[static 1][2]);
42
43void fia1x1_2x1 (int[1][1]); // { dg-message "previously declared as 'int\\\[1]\\\[1]'" }
44void fia1x1_2x1 (int[2][1]); // { dg-warning "\\\[-Warray-parameter" }
45void fia1x1_2x1 (int[static 1][1]);
46void fia1x1_2x1 (int[static 2][1]); // { dg-warning "\\\[-Warray-parameter" }
47
48
49void fia2x1_1x1 (int[2][1]); // { dg-message "previously declared as 'int\\\[2]\\\[1]'" }
50void fia2x1_1x1 (int[1][1]); // { dg-warning "\\\[-Warray-parameter" }
51void fia2x1_1x1 (int[2][1]);
52void fia2x1_1x1 (int[static 1][1]); // { dg-warning "\\\[-Warray-parameter" }
53void fia2x1_1x1 (int[static 2][1]);
54
55
56extern int n1, n2;
57
58void fca_xn1 (char[][n1]);
59void fca_xn1 (char[0][n1]);
60void fca_xn1 (char[static 0][n1]);
61
62void fca1xn1_2xn1 (char[1][n1]);
63void fca1xn1_2xn1 (char[2][n1]); // { dg-warning "\\\[-Warray-parameter" }
64void fca1xn1_2xn1 (char[1][n1]);
65void fca1xn1_2xn1 (char[static 1][n1]);
66void fca1xn1_2xn1 (char[static 2][n1]); // { dg-warning "\\\[-Warray-parameter" }
67
68
69/* Exercise VLAs with a mismatch in the bound for an ordinary array. */
70void fvlax_y (int n, int[][n]);
71void fvlax_y (int n, int[0][n]);
72void fvlax_y (int n, int[1][n]); // { dg-warning "argument 2 of type 'int\\\[1]\\\[n]' with mismatched bound" }
73void fvlax_y (int n, int[2][n]); // { dg-warning "argument 2 of type 'int\\\[2]\\\[n]' with mismatched bound" }
74void fvlax_y (int n, int[3][n]); // { dg-warning "argument 2 of type 'int\\\[3]\\\[n]' with mismatched bound" }
75
76void fvlaxn_y (int n, int[][n]);
77void fvlaxn_y (int n, int[0][n]);
78void fvlaxn_y (int n, int[1][n]); // { dg-warning "\\\[-Warray-parameter" }
79void fvlaxn_y (int n, int[2][n]); // { dg-warning "\\\[-Warray-parameter" }
80void fvlaxn_y (int n, int[3][n]); // { dg-warning "\\\[-Warray-parameter" }
81
82void fvlaxx_y (int[][*]);
83void fvlaxx_y (int[0][*]);
84void fvlaxx_y (int[1][*]); // { dg-warning "\\\[-Warray-parameter" }
85void fvlaxx_y (int[2][*]); // { dg-warning "\\\[-Warray-parameter" }
86void fvlaxx_y (int[3][*]); // { dg-warning "\\\[-Warray-parameter" }
87
88
89// Verify an array of pointers to an array of function pointers.
90
91void ffpa7_5 (void (* (* (* [7])[5])(void))(void));
92// { dg-message "previously declared as 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[7]\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "note" { target *-*-* } .-1 }
93void ffpa7_5 (void (* (* (* [6])[5])(void))(void));
94// { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[6]\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 }
95void ffpa7_5 (void (* (* (* [])[5])(void))(void));
96// { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[]\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 }
97void ffpa7_5 (void (* (* (* (*))[5])(void))(void));
98// { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\*\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)' declared as a pointer" "" { target *-*-* } .-1 }
99
100// Same as above but with array of pointers to a VLA of function pointers.
101void ffpa7_n1 (void (* (* (* [7])[n1])(void))(void));
102// { dg-message "previously declared as 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[7]\\\)\\\[n1]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "note" { target *-*-* } .-1 }
103void ffpa7_n1 (void (* (* (* [8])[n1])(void))(void));
104// { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[8]\\\)\\\[n1]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 }
105
106void 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 }
109void 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 }
112
113/* Verify a three-dimensional array of pointers to two-dimensional arrays
114 of pointers to function pointers. */
115
116void ffpa7_5_3 (void (* (* (* (* [7])[5])[3])(void))(void));
117// { dg-message "previously declared as 'void ?\\\(\\\* ?\\\(\\\* ?\\\(\\\* ?\\\(\\\* ?\\\[7]\\\)\\\[5]\\\)\\\[3]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "note" { target *-*-* } .-1 }
118void 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 }