Debian Codegraph @

gcc/testsuite/g++.dg/opt/nrv27.C

raw
1 // PR c++/53637
2 // { dg-additional-options "-Wnrvo -fdump-tree-gimple" }
3
4 class Foo {
5 public:
6 Foo() {}
7 Foo(const Foo& other);
8 };
9
10 Foo bar(int i) {
11 if (i > 1) {
12 Foo result;
13 return result; // We currently elide this copy, but not the second one.
14 // { dg-final { scan-tree-dump {result .value-expr} "gimple" } }
15 } else {
16 Foo result;
17 return result; // { dg-bogus "not eliding copy on return from" "" { xfail *-*-* } }
18 }
19 }
20
21 int main(int argc, char* argv[]) {
22 Foo f = bar(argc);
23 }