From: Jason Merrill Date: Fri, 18 Jan 2002 13:24:04 +0000 (-0500) Subject: also test with inlining X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cc0723165e7aa03d4f07f542452ca7cbb7912d69;p=gcc.git also test with inlining From-SVN: r48984 --- diff --git a/gcc/testsuite/g++.dg/opt/nrv2.C b/gcc/testsuite/g++.dg/opt/nrv2.C new file mode 100644 index 00000000000..4ffc075878d --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/nrv2.C @@ -0,0 +1,28 @@ +// Test for the named return value optimization, this time with inlining. +// { dg-do run } +// { dg-options -O2 } + +int c; +int d; + +struct A +{ + A() { ++c; } + A(const A&) { ++c; }; + ~A() { ++d; } +}; + +inline A f () +{ + A a; + return a; +} + +int main () +{ + { + A a = f (); + } + + return !(c == 1 && c == d); +}