]>
Commit | Line | Data |
---|---|---|
6450f073 MS |
1 | /* PR c/50584 - No warning for passing small array to C99 static array |
2 | declarator | |
3 | Verify warnings for redeclarations of functions with pointer parameters | |
4 | to arrays with variable bounds involving typedefs. | |
5 | { dg-do compile } | |
6 | { dg-options "-Wall -Wvla-parameter" } */ | |
7 | ||
8 | extern int m, n; | |
9 | ||
10 | typedef int IA3[3]; | |
11 | ||
12 | /* Verify the warning points to the declaration with more unspecified | |
13 | bounds, guiding the user to specify them rather than making them all | |
14 | unspecified. */ | |
15 | void* f_pIA3ax (IA3 *x[*]); // { dg-warning "argument 1 of type 'int \\\(\\\*\\\[\\\*]\\\)\\\[3]' .aka '\[^\n\r\}\]+'. declared with 1 unspecified variable bound" } | |
16 | void* f_pIA3ax (IA3 *x[*]); | |
17 | void* f_pIA3ax (IA3 *x[n]); // { dg-message "subsequently declared as 'int \\\(\\\*\\\[n]\\\)\\\[3]' with 0 unspecified variable bounds" "note" } | |
18 | void* f_pIA3ax (IA3 *x[n]) { return x; } | |
19 | ||
20 | ||
21 | void* f_pIA3an (IA3 *x[n]); // { dg-message "previously declared as 'int \\\(\\\*\\\[n]\\\)\\\[3]' with 0 unspecified variable bounds" "note" } | |
22 | void* f_pIA3an (IA3 *x[n]); | |
23 | void* f_pIA3an (IA3 *x[*]); // { dg-warning "argument 1 of type 'int \\\(\\\*\\\[\\\*]\\\)\\\[3]' .aka '\[^\n\r\}\]+'. declared with 1 unspecified variable bound" } | |
24 | void* f_pIA3an (IA3 *x[n]) { return x; } | |
25 | ||
26 | ||
27 | void nowarn_local_fndecl (void) | |
28 | { | |
29 | typedef int IAm[m]; | |
30 | ||
31 | void* f_IAm (IAm); | |
32 | void* f_IAm (int[m]); | |
33 | void* f_IAm (IAm); | |
34 | ||
35 | void* f_iam (int[m]); | |
36 | void* f_iam (IAm); | |
37 | void* f_iam (int[m]); | |
38 | ||
39 | typedef int IA3[3]; | |
40 | typedef IA3 IAn_3[n]; | |
41 | typedef IAn_3 IA2_n_3[2]; | |
42 | typedef IA2_n_3 IAm_2_n_3[m]; | |
43 | ||
44 | void f_IAm_2_n_3 (IAm_2_n_3); | |
45 | void f_IAm_2_n_3 (IA2_n_3[m]); | |
46 | void f_IAm_2_n_3 (IAn_3[m][2]); | |
47 | void f_IAm_2_n_3 (IA3[m][2][n]); | |
48 | void f_IAm_2_n_3 (int[m][2][n][3]); | |
49 | ||
50 | void f_iam_2_n_3 (int[m][2][n][3]); | |
51 | void f_iam_2_n_3 (IA3[m][2][n]); | |
52 | void f_iam_2_n_3 (IAn_3[m][2]); | |
53 | void f_iam_2_n_3 (IAm_2_n_3); | |
54 | ||
55 | void f_IAx_m_2_n_3 (IAm_2_n_3[*]); | |
56 | void f_IAx_m_2_n_3 (IA2_n_3[*][m]); | |
57 | void f_IAx_m_2_n_3 (IAn_3[*][m][2]); | |
58 | void f_IAx_m_2_n_3 (IA3[*][m][2][n]); | |
59 | void f_IAx_m_2_n_3 (int[*][m][2][n][3]); | |
60 | ||
61 | void f_IA__m_2_n_3 (IAm_2_n_3[]); | |
62 | void f_IA__m_2_n_3 (IA2_n_3[][m]); | |
63 | void f_IA__m_2_n_3 (IAn_3[][m][2]); | |
64 | void f_IA__m_2_n_3 (IA3[][m][2][n]); | |
65 | void f_IA__m_2_n_3 (int[][m][2][n][3]); | |
66 | } | |
67 | ||
68 | ||
69 | void warn_local_fndecl (void) | |
70 | { | |
71 | typedef int IAm[m]; | |
72 | typedef int IAn[n]; | |
73 | ||
74 | void* g_IAm (IAm); // { dg-message "previously declared as 'int\\\[m]' with bound 'm'" } | |
75 | void* g_IAm (int[n]); // { dg-warning "argument 1 of type 'int\\\[n]' declared with mismatched bound 'n'" } | |
76 | void* g_IAm (IAm); | |
77 | ||
78 | void* g_iam (int[m]); // { dg-message "previously declared as 'int\\\[m]' with bound 'm'" } | |
79 | void* g_iam (IAn); // { dg-warning "argument 1 of type 'int\\\[n]' declared with mismatched bound 'n'" } | |
80 | void* g_iam (int[m]); | |
81 | ||
82 | ||
83 | typedef int IA3[3]; | |
84 | typedef IA3 IAn_3[n]; | |
85 | typedef IAn_3 IA2_n_3[2]; | |
86 | typedef IA2_n_3 IAm_2_n_3[m]; | |
87 | ||
88 | typedef IA3 IAm_3[m]; | |
89 | typedef IAm_3 IA2_m_3[2]; | |
90 | typedef IA2_m_3 IAm_2_m_3[m]; | |
91 | ||
92 | void* g_IAm_2_n_3 (IAm_2_n_3); | |
93 | void* g_IAm_2_n_3 (int[m][2][m][3]); // { dg-warning "argument 1 of type 'int\\\[m]\\\[2]\\\[m]\\\[3]' declared with mismatched bound 'm'" } | |
94 | void* g_IAm_2_n_3 (IAm_2_n_3); | |
95 | ||
96 | void* g_iam_2_n_2 (int[m][2][n][3]); | |
97 | void* g_iam_2_n_2 (IAm_2_m_3); // { dg-warning "argument 1 of type 'int\\\[m]\\\[2]\\\[m]\\\[3]' declared with mismatched bound 'm'" } | |
98 | void* g_iam_2_n_2 (int[m][2][n][3]); | |
99 | } |