annotate gcc/testsuite/gcc.dg/attr-alloc_size-9.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* PR c/78284 - warn on malloc with very large arguments
kono
parents:
diff changeset
2 Test verifying that the built-in allocation functions are declared
kono
parents:
diff changeset
3 with attribute malloc. This means that the pointer they return
kono
parents:
diff changeset
4 can be assumed not to alias any other valid pointer. */
kono
parents:
diff changeset
5 /* { dg-do compile } */
kono
parents:
diff changeset
6 /* { dg-require-effective-target alloca } */
kono
parents:
diff changeset
7 /* { dg-options "-O2 -fdump-tree-optimized" } */
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 void sink (void*);
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 extern int x;
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 #define TEST(call) \
kono
parents:
diff changeset
14 do { \
kono
parents:
diff changeset
15 p = call; \
kono
parents:
diff changeset
16 x = 123; \
kono
parents:
diff changeset
17 *(int*)p = 456; \
kono
parents:
diff changeset
18 (x == 123) ? (void)0 : __builtin_abort (); \
kono
parents:
diff changeset
19 sink (p); \
kono
parents:
diff changeset
20 } while (0)
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 void test (void *p, unsigned n)
kono
parents:
diff changeset
23 {
kono
parents:
diff changeset
24 TEST (__builtin_aligned_alloc (8, n));
kono
parents:
diff changeset
25 TEST (__builtin_alloca (n));
kono
parents:
diff changeset
26 TEST (__builtin_calloc (4, n));
kono
parents:
diff changeset
27 TEST (__builtin_malloc (n));
kono
parents:
diff changeset
28 TEST (__builtin_realloc (p, n + 1));
kono
parents:
diff changeset
29 }
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 /* { dg-final { scan-tree-dump-not "abort" "optimized" } } */