Debian Codegraph @

gcc/testsuite/g++.dg/guality/pr82630.C

raw
1 // PR debug/82630
2 // { dg-do run }
3 // { dg-additional-options "-fPIC" { target fpic } }
4
5 struct C
6 {
7 int &c;
8 long d;
9 __attribute__((always_inline)) C (int &x) : c(x), d() {}
10 };
11 int v;
12
13 __attribute__((noipa)) void
14 fn1 (const void *x)
15 {
16 asm volatile ("" : : "g" (x) : "memory");
17 }
18
19 __attribute__((noipa)) void
20 fn2 (C x)
21 {
22 int a = x.c + x.d;
23 asm volatile ("" : : "g" (a) : "memory");
24 }
25
26 __attribute__((noipa)) void
27 fn3 (void)
28 {
29 asm volatile ("" : : : "memory");
30 }
31
32 __attribute__((noipa))
33 #ifdef __i386__
34 __attribute__((regparm (2)))
35 #endif
36 static void
37 fn4 (int *x, const char *y, C z)
38 {
39 fn2 (C (*x));
40 fn1 ("baz");
41 fn2 (z); // { dg-final { gdb-test 41 "y\[0\]" "'f'" } }
42 fn1 ("baz"); // { dg-final { gdb-test 41 "y\[1\]" "'o'" } }
43 }
44
45 __attribute__((noipa)) void
46 fn5 (int *x)
47 {
48 fn4 (x, "foo", C (*x));
49 fn3 ();
50 }
51
52 int
53 main ()
54 {
55 int a = 10;
56 fn5 (&a);
57 return 0;
58 }