Debian Codegraph @

gcc/testsuite/g++.dg/ipa/modref-1.C

raw
1 /* { dg-do link } */
2 /* { dg-options "-O2 -fdump-tree-local-pure-const1 -fdump-tree-modref1 -std=gnu++2a" } */
3 namespace {
4 struct B {
5 int b;
6 struct B *bptr;
7 B() {b=1; }
8 B(B &src)
9 {
10 b=src.b;
11 bptr=0;
12 }
13 __attribute__ ((noinline))
14 static struct B genB()
15 {
16 struct B b;
17 b.b=2;
18 b.bptr = 0;
19 return b;
20 }
21 };
22 }
23 void linker_error ();
24 int main()
25 {
26 struct B b1 = B::genB();
27 b1.b = 1;
28 struct B b2 = B::genB();
29 if (b1.b != 1 || b2.bptr == &b2)
30 linker_error ();
31 return 0;
32 }
33 /* { dg-final { scan-tree-dump "Function found to be const: static {anonymous}::B {anonymous}::B::genB" "local-pure-const1" } } */
34 /* { dg-final { scan-tree-dump "Retslot flags: not_returned_directly" "modref1" } } */
35