2017-12-05 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / Walloca-3.c
blobf5840673da0391577da8bf387d6544c4bfd37c32
1 /* { dg-do compile } */
2 /* { dg-require-effective-target alloca } */
3 /* { dg-options "-Walloca-larger-than=2000 -O2" } */
5 void f (void *);
7 __SIZE_TYPE__ LIMIT;
9 // Warn when there is an alloca bound, but it is an unknown bound.
11 void
12 g1 (__SIZE_TYPE__ n)
14 void *p;
15 if (n < LIMIT)
16 p = __builtin_alloca (n); // { dg-warning "'alloca' bound is unknown" }
17 else
18 p = __builtin_malloc (n);
19 f (p);
22 // Similar to the above, but do not get confused by the upcast.
24 unsigned short SHORT_LIMIT;
25 void
26 g2 (unsigned short n)
28 void *p;
29 if (n < SHORT_LIMIT)
30 p = __builtin_alloca (n); // { dg-warning "'alloca' bound is unknown" }
31 else
32 p = __builtin_malloc (n);
33 f (p);