aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>2002-01-18 08:24:04 -0500
committerJason Merrill <jason@gcc.gnu.org>2002-01-18 08:24:04 -0500
commitcc0723165e7aa03d4f07f542452ca7cbb7912d69 (patch)
tree8e2666d4d01ea9ec07062b8776ff1f845ba6bac6
parent4ffbff5906ce6291c39852f0856b5f6a60a3d3e1 (diff)
downloadgcc-cc0723165e7aa03d4f07f542452ca7cbb7912d69.zip
gcc-cc0723165e7aa03d4f07f542452ca7cbb7912d69.tar.gz
gcc-cc0723165e7aa03d4f07f542452ca7cbb7912d69.tar.bz2
also test with inlining
From-SVN: r48984
-rw-r--r--gcc/testsuite/g++.dg/opt/nrv2.C28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/opt/nrv2.C b/gcc/testsuite/g++.dg/opt/nrv2.C
new file mode 100644
index 0000000..4ffc075
--- /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);
+}