2016-12-07 Thomas Preud'homme <thomas.preudhomme@arm.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / Walloca-2.c
blob4695fda400b1ca8dc91a4ad0d7c4f257e030c8a1
1 /* { dg-do compile } */
2 /* { dg-options "-Walloca-larger-than=2000 -O2" } */
4 void f (void *);
6 void
7 g1 (int n)
9 void *p;
10 if (n > 0 && n < 2000)
11 // FIXME: This is a bogus warning, and is currently happening on
12 // 32-bit targets because VRP is not giving us any range info for
13 // the argument to __builtin_alloca. This should be fixed by the
14 // upcoming range work.
15 p = __builtin_alloca (n); // { dg-bogus "unbounded use of 'alloca'" "" { xfail { ! lp64 } } }
16 else
17 p = __builtin_malloc (n);
18 f (p);
21 void
22 g2 (int n)
24 void *p;
25 if (n < 2000)
26 p = __builtin_alloca (n); // { dg-warning "large due to conversion" }
27 else
28 p = __builtin_malloc (n);
29 f (p);
32 void
33 g3 (int n)
35 void *p;
36 if (n > 0 && n < 3000)
38 p = __builtin_alloca (n); // { dg-warning "'alloca' may be too large" "" { target lp64} }
39 // { dg-message "note:.*argument may be as large as 2999" "note" { target lp64 } 38 }
40 // { dg-warning "unbounded use of 'alloca'" "" { target { ! lp64 } } 38 }
42 else
43 p = __builtin_malloc (n);
44 f (p);