Debian Codegraph @

gcc/testsuite/gcc.dg/Walloc-size-1.c

raw
1 /* Tests the warnings for insufficient allocation size.
2 { dg-do compile }
3 { dg-options "-Walloc-size" }
4 * */
5
6 struct b { int x[10]; };
7
8 void fo0(void)
9 {
10 struct b *p = __builtin_malloc(sizeof *p);
11 }
12
13 void fo1(void)
14 {
15 struct b *p = __builtin_malloc(sizeof p); /* { dg-warning "allocation of insufficient size" } */
16 }
17
18 void fo2(void)
19 {
20 struct b *p = __builtin_alloca(sizeof p); /* { dg-warning "allocation of insufficient size" } */
21 }
22
23 void fo3(void)
24 {
25 struct b *p = __builtin_calloc(1, sizeof p); /* { dg-warning "allocation of insufficient size" } */
26 }
27
28 void g(struct b* p);
29
30 void fo4(void)
31 {
32 g(__builtin_malloc(4)); /* { dg-warning "allocation of insufficient size" } */
33 }
34