1 /* PR c/50584 - No warning for passing small array to C99 static array
3 Verify warnings for redeclarations of functions with pointer parameters
4 to arrays with variable bounds involving typedefs.
6 { dg-options "-Wall -Wvla-parameter" } */
12 /* Verify the warning points to the declaration with more unspecified
13 bounds, guiding the user to specify them rather than making them all
16 void* f_pIA3an (IA3
*x
[n
]); // { dg-message "previously declared as 'int \\\(\\\*\\\[n]\\\)\\\[3]' with 0 unspecified variable bounds" "note" }
17 void* f_pIA3an (IA3
*x
[n
]);
18 void* f_pIA3an (IA3
*x
[*]); // { dg-warning "argument 1 of type 'int \\\(\\\*\\\[\\\*]\\\)\\\[3]' .aka '\[^\n\r\}\]+'. declared with 1 unspecified variable bound" }
19 void* f_pIA3an (IA3
*x
[n
]) { return x
; }
22 void nowarn_local_fndecl (void)
36 typedef IAn_3 IA2_n_3
[2];
37 typedef IA2_n_3 IAm_2_n_3
[m
];
39 void f_IAm_2_n_3 (IAm_2_n_3
);
40 void f_IAm_2_n_3 (IA2_n_3
[m
]);
41 void f_IAm_2_n_3 (IAn_3
[m
][2]);
42 void f_IAm_2_n_3 (IA3
[m
][2][n
]);
43 void f_IAm_2_n_3 (int[m
][2][n
][3]);
45 void f_iam_2_n_3 (int[m
][2][n
][3]);
46 void f_iam_2_n_3 (IA3
[m
][2][n
]);
47 void f_iam_2_n_3 (IAn_3
[m
][2]);
48 void f_iam_2_n_3 (IAm_2_n_3
);
50 void f_IAx_m_2_n_3 (IAm_2_n_3
[*]);
51 void f_IAx_m_2_n_3 (IA2_n_3
[*][m
]);
52 void f_IAx_m_2_n_3 (IAn_3
[*][m
][2]);
53 void f_IAx_m_2_n_3 (IA3
[*][m
][2][n
]);
54 void f_IAx_m_2_n_3 (int[*][m
][2][n
][3]);
56 void f_IA__m_2_n_3 (IAm_2_n_3
[]);
57 void f_IA__m_2_n_3 (IA2_n_3
[][m
]);
58 void f_IA__m_2_n_3 (IAn_3
[][m
][2]);
59 void f_IA__m_2_n_3 (IA3
[][m
][2][n
]);
60 void f_IA__m_2_n_3 (int[][m
][2][n
][3]);
64 void warn_local_fndecl (void)
69 void* g_IAm (IAm
); // { dg-message "previously declared as 'int\\\[m]' with bound 'm'" }
70 void* g_IAm (int[n
]); // { dg-warning "argument 1 of type 'int\\\[n]' declared with mismatched bound 'n'" }
73 void* g_iam (int[m
]); // { dg-message "previously declared as 'int\\\[m]' with bound 'm'" }
74 void* g_iam (IAn
); // { dg-warning "argument 1 of type 'int\\\[n]' declared with mismatched bound 'n'" }
80 typedef IAn_3 IA2_n_3
[2];
81 typedef IA2_n_3 IAm_2_n_3
[m
];
84 typedef IAm_3 IA2_m_3
[2];
85 typedef IA2_m_3 IAm_2_m_3
[m
];
87 void* g_IAm_2_n_3 (IAm_2_n_3
);
88 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'" }
89 void* g_IAm_2_n_3 (IAm_2_n_3
);
91 void* g_iam_2_n_2 (int[m
][2][n
][3]);
92 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'" }
93 void* g_iam_2_n_2 (int[m
][2][n
][3]);