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 *);
14 void foo1 (size_t len
, size_t len2
, size_t len3
)
18 for (i
=0; i
< 123; ++i
)
20 char *s
= alloca (566); /* { dg-warning "'alloca' within a loop" } */
24 char *s
= alloca (123);
25 useit (s
); // OK, constant argument to alloca
27 s
= alloca (num
); // { dg-warning "large due to conversion" "" { target lp64 } }
28 // { dg-warning "unbounded use of 'alloca'" "" { target { ! lp64 } } .-1 }
31 s
= alloca (30000); /* { dg-warning "is too large" } */
36 s
= alloca(len
); // OK, bounded
40 if (len
+ len2
< 2000) // OK, bounded
42 s
= alloca(len
+ len2
);
48 s
= alloca(len3
); /* { dg-warning "may be too large" } */
53 void foo2 (__SIZE_TYPE__ len
)
55 // Test that a direct call to __builtin_alloca_with_align is not confused
57 void *p
= __builtin_alloca_with_align (len
, 8); // { dg-warning "unbounded use of 'alloca'" }
61 void foo3 (unsigned char a
)
64 useit (__builtin_alloca (a
)); // { dg-warning "argument to 'alloca' is zero" }