libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / Walloc-size-1.c
blobcae5e0708456f8bc75da5efad3c980e595d22eff
1 /* Tests the warnings for insufficient allocation size.
2 { dg-do compile }
3 { dg-options "-Walloc-size" }
4 * */
6 struct b { int x[10]; };
8 void fo0(void)
10 struct b *p = __builtin_malloc(sizeof *p);
13 void fo1(void)
15 struct b *p = __builtin_malloc(sizeof p); /* { dg-warning "allocation of insufficient size" } */
18 void fo2(void)
20 struct b *p = __builtin_alloca(sizeof p); /* { dg-warning "allocation of insufficient size" } */
23 void fo3(void)
25 struct b *p = __builtin_calloc(1, sizeof p); /* { dg-warning "allocation of insufficient size" } */
28 void g(struct b* p);
30 void fo4(void)
32 g(__builtin_malloc(4)); /* { dg-warning "allocation of insufficient size" } */