PR tree-optimization/86401
[official-gcc.git] / gcc / testsuite / c-c++-common / sizeof-array-argument.c
blobeedfceec2cfc8502e2779b414cb7888446691313
1 /* PR c/6940 */
2 /* { dg-do compile } */
4 /* Test -Wsizeof-array-argument warning. */
6 typedef int T[2][2];
8 int
9 fn1 (int a[])
11 return sizeof a; /* { dg-warning "on array function parameter" } */
14 int
15 fn2 (int x, int b[3])
17 return x + sizeof b; /* { dg-warning "on array function parameter" } */
20 int
21 fn3 (int *p)
23 return sizeof p;
26 int fn4 (int *p);
27 int
28 fn4 (int p[])
30 return sizeof p; /* { dg-warning "on array function parameter" } */
33 int fn5 (int x[]);
34 int
35 fn5 (int *x)
37 return sizeof x;
40 #ifndef __cplusplus
41 /* C++ doesn't know VLA unspec. */
42 int fn6 (int x[*]);
43 int
44 fn6 (int x[])
46 return sizeof x; /* { dg-warning "on array function parameter" "" { target c } } */
48 #endif
50 int
51 fn7 (int x[][2])
53 return sizeof x; /* { dg-warning "on array function parameter" } */
56 int
57 fn8 (char *x[])
59 return sizeof x; /* { dg-warning "on array function parameter" } */
62 int
63 fn9 (char **x)
65 return sizeof x;
68 #ifndef __cplusplus
69 int
70 fn10 (int a, char x[static sizeof a])
72 return sizeof x; /* { dg-warning "on array function parameter" "" { target c } } */
75 int
76 fn11 (a)
77 char a[];
79 return sizeof a; /* { dg-warning "on array function parameter" "" { target c } } */
82 int
83 fn12 (a)
84 char *a;
86 return sizeof a;
88 #endif
90 int
91 fn13 (char (*x)[2])
93 return sizeof x;
96 int
97 fn14 (T t)
99 return sizeof t; /* { dg-warning "on array function parameter" } */