i386: Fix some ISA bit test in option_override
[official-gcc.git] / gcc / testsuite / gcc.dg / Walloca-1.c
blob37ee1912187717ce3e1440cef4bf200b6af29949
1 /* { dg-do compile } */
2 /* { dg-require-effective-target alloca } */
3 /* { dg-options "-Walloca-larger-than=2000 -O2 -ftrack-macro-expansion=0" } */
5 #define alloca __builtin_alloca
7 typedef __SIZE_TYPE__ size_t;
8 extern size_t strlen(const char *);
10 extern void useit (char *);
12 int num;
14 void foo1 (size_t len, size_t len2, size_t len3)
16 int i;
18 for (i=0; i < 123; ++i)
20 char *s = alloca (566); /* { dg-warning "'alloca' within a loop" } */
21 useit (s);
24 char *s = alloca (123);
25 useit (s); // OK, constant argument to alloca
27 s = alloca (num); // { dg-warning "\(may be too large|unbounded use\)" }
28 useit (s);
30 s = alloca (30000); /* { dg-warning "is too large" } */
31 useit (s);
33 if (len < 2000)
35 s = alloca(len); // OK, bounded
36 useit (s);
39 if (len + len2 < 2000) // OK, bounded
41 s = alloca(len + len2);
42 useit (s);
45 if (len3 <= 2001)
47 s = alloca(len3); /* { dg-warning "may be too large" } */
48 useit(s);
52 void foo2 (__SIZE_TYPE__ len)
54 // Test that a direct call to __builtin_alloca_with_align is not confused
55 // with a VLA.
56 void *p = __builtin_alloca_with_align (len, 8); // { dg-warning "unbounded use of 'alloca'" }
57 useit (p);
60 void foo3 (unsigned char a)
62 if (a == 0)
63 useit (__builtin_alloca (a)); // { dg-warning "argument to 'alloca' is zero" }