also test with inlining
authorJason Merrill <jason@gcc.gnu.org>
Fri, 18 Jan 2002 13:24:04 +0000 (08:24 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 18 Jan 2002 13:24:04 +0000 (08:24 -0500)
From-SVN: r48984

gcc/testsuite/g++.dg/opt/nrv2.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/opt/nrv2.C b/gcc/testsuite/g++.dg/opt/nrv2.C
new file mode 100644 (file)
index 0000000..4ffc075
--- /dev/null
@@ -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);
+}