1cf9165c59f9e813e535d56d36e713884770a4ce
[gcc.git] / gcc / testsuite / gcc.dg / Walloca-2.c
1 /* { dg-do compile } */
2 /* { dg-require-effective-target alloca } */
3 /* { dg-options "-Walloca-larger-than=2000 -O2" } */
4
5 void f (void *);
6
7 void
8 g1 (int n)
9 {
10 void *p;
11 if (n > 0 && n < 2000)
12 // FIXME: This is a bogus warning, and is currently happening on
13 // 32-bit targets because VRP is not giving us any range info for
14 // the argument to __builtin_alloca. This should be fixed by the
15 // upcoming range work.
16 p = __builtin_alloca (n); // { dg-bogus "unbounded use of 'alloca'" "" { xfail { ! lp64 } } }
17 else
18 p = __builtin_malloc (n);
19 f (p);
20 }
21
22 void
23 g2 (int n)
24 {
25 void *p;
26 if (n < 2000)
27 p = __builtin_alloca (n); // { dg-warning "may be too large" }
28 else
29 p = __builtin_malloc (n);
30 f (p);
31 }
32
33 void
34 g3 (int n)
35 {
36 void *p;
37 if (n > 0 && n < 3000)
38 {
39 p = __builtin_alloca (n); // { dg-warning "may be too large" }
40 }
41 else
42 p = __builtin_malloc (n);
43 f (p);
44 }