PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / Walloca-5.c
blob73c72960c264214f18f051dae5a29ae2e5370e07
1 /* { dg-do compile } */
2 /* { dg-require-effective-target alloca } */
3 /* { dg-options "-Walloca-larger-than=123 -O2" } */
4 /* { dg-xfail-if "Currently broken but Andrew's work should fix this" { *-*-* } } */
6 /* The argument to alloca ends up having a range of 0..MAXINT(32bits),
7 so we think we have a range because of the upcast. Consequently,
8 we warn with "alloca may be too large", but we should technically
9 warn with "unbounded use of alloca".
11 We currently drill through casts to figure this stuff out, but we
12 get confused because it's not just a cast. It's a cast, plus a
13 multiply.
15 <bb 2>:
16 # RANGE [0, 4294967295] NONZERO 4294967295
17 _1 = (long unsigned int) something_4(D);
18 # RANGE [0, 34359738360] NONZERO 34359738360
19 _2 = _1 * 8;
20 _3 = __builtin_alloca (_2);
22 I don't know whether it's even worth such fine-grained warnings.
23 Perhaps we should generically warn everywhere with "alloca may be
24 too large".
26 I'm hoping that this particular case will be easier to diagnose with
27 Andrew's work. */
29 void useit(void *);
30 void foobar(unsigned int something)
32 useit(__builtin_alloca (something * sizeof (const char *))); // { dg-warning "unbounded use of alloca" "" { xfail *-*-* } }