c++: prev declared hidden tmpl friend inst [PR112288]
[official-gcc.git] / gcc / testsuite / gcc.dg / ipa / pr110378-4.c
blob32432a8dbe7386fd780f9668760d7b03193794a8
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-ipa-sra -fdump-tree-optimized-slim" } */
4 /* This emulates what C++ trstcase pr110378-1.C looks like on 32-bit arm (or
5 any architecture where the destructor returns this pointer. It verifies
6 that when it later becomes known that the return value will be removed, we
7 can split a parameter even in this case. */
9 struct S
11 short move_offset_of_a;
12 int *a;
15 extern int *allocate_stuff (unsigned);
16 extern void deallocate_stuff (void *);
18 static void
19 something_like_a_constructor (struct S *p, int len)
21 p->a = allocate_stuff (len * sizeof (int));
22 *p->a = 4;
25 static int
26 operation (struct S *p)
28 return *p->a + 1;
31 static struct S * __attribute__((noinline))
32 something_like_an_arm32_destructor (struct S *p)
34 deallocate_stuff (p->a);
35 return p;
38 volatile int v2 = 20;
40 int test (void)
42 struct S shouldnotexist;
43 something_like_a_constructor (&shouldnotexist, v2);
44 v2 = operation (&shouldnotexist);
45 something_like_an_arm32_destructor (&shouldnotexist);
46 return 0;
49 /* { dg-final { scan-ipa-dump "Will split parameter 0" "sra" } } */
50 /* { dg-final { scan-tree-dump-not "shouldnotexist" "optimized" } } */