1 /* PR c/83989 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -Wrestrict" } */
4
5 __attribute__((__malloc__)) extern void *my_malloc (__SIZE_TYPE__);
6 void baz (void *);
7
8 #define SIZE 32
9
10 void
11 foo (void)
12 {
13 void *recmem = __builtin_malloc (SIZE);
14 baz (recmem);
15 while (1)
16 {
17 void *oldrecmem = recmem;
18 recmem = __builtin_malloc (SIZE);
19 if (!recmem)
20 {
21 __builtin_free (oldrecmem);
22 return;
23 }
24 __builtin_memcpy (recmem, oldrecmem, SIZE); /* { dg-bogus "accessing" } */
25 baz (recmem);
26 __builtin_free (oldrecmem);
27 }
28 }
29
30 void
31 bar (void)
32 {
33 void *recmem = my_malloc (SIZE);
34 baz (recmem);
35 while (1)
36 {
37 void *oldrecmem = recmem;
38 recmem = my_malloc (SIZE);
39 if (!recmem)
40 {
41 __builtin_free (oldrecmem);
42 return;
43 }
44 __builtin_memcpy (recmem, oldrecmem, SIZE); /* { dg-bogus "accessing" } */
45 baz (recmem);
46 __builtin_free (oldrecmem);
47 }
48 }