111
|
1 /* PR c/78284 - warn on malloc with very large arguments
|
|
2 Test verifying that the built-in allocation functions are declared
|
|
3 with attribute malloc. This means that the pointer they return
|
|
4 can be assumed not to alias any other valid pointer. */
|
|
5 /* { dg-do compile } */
|
|
6 /* { dg-require-effective-target alloca } */
|
|
7 /* { dg-options "-O2 -fdump-tree-optimized" } */
|
|
8
|
|
9 void sink (void*);
|
|
10
|
|
11 extern int x;
|
|
12
|
|
13 #define TEST(call) \
|
|
14 do { \
|
|
15 p = call; \
|
|
16 x = 123; \
|
|
17 *(int*)p = 456; \
|
|
18 (x == 123) ? (void)0 : __builtin_abort (); \
|
|
19 sink (p); \
|
|
20 } while (0)
|
|
21
|
|
22 void test (void *p, unsigned n)
|
|
23 {
|
|
24 TEST (__builtin_aligned_alloc (8, n));
|
|
25 TEST (__builtin_alloca (n));
|
|
26 TEST (__builtin_calloc (4, n));
|
|
27 TEST (__builtin_malloc (n));
|
|
28 TEST (__builtin_realloc (p, n + 1));
|
|
29 }
|
|
30
|
|
31 /* { dg-final { scan-tree-dump-not "abort" "optimized" } } */
|