]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/Walloca-3.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / Walloca-3.c
CommitLineData
adc577c5 1/* { dg-do compile } */
90e02692 2/* { dg-require-effective-target alloca } */
adc577c5
AH
3/* { dg-options "-Walloca-larger-than=2000 -O2" } */
4
5void f (void *);
6
7__SIZE_TYPE__ LIMIT;
8
9// Warn when there is an alloca bound, but it is an unknown bound.
10
11void
12g1 (__SIZE_TYPE__ n)
13{
14 void *p;
15 if (n < LIMIT)
495ec0b2 16 p = __builtin_alloca (n); // { dg-warning "may be too large" }
adc577c5
AH
17 else
18 p = __builtin_malloc (n);
19 f (p);
20}
21
22// Similar to the above, but do not get confused by the upcast.
23
24unsigned short SHORT_LIMIT;
25void
26g2 (unsigned short n)
27{
28 void *p;
29 if (n < SHORT_LIMIT)
495ec0b2 30 p = __builtin_alloca (n); // { dg-warning "may be too large" }
adc577c5
AH
31 else
32 p = __builtin_malloc (n);
33 f (p);
34}