summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/g++.dg/cpp0x/rvo.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/rvo.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/rvo.C25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/rvo.C b/gcc/testsuite/g++.dg/cpp0x/rvo.C
new file mode 100644
index 00000000000..b52ce7495db
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rvo.C
@@ -0,0 +1,25 @@
+// { dg-do "run" }
+// { dg-options "-std=c++0x" }
+// Contributed by Sylvain Pion
+static int rvalue_constructions = 0;
+
+struct A {
+ A () { }
+ A (const A&) { }
+ A (A&&) { ++rvalue_constructions; }
+ ~A () { }
+};
+
+A f() { return A(); }
+
+extern "C" {
+ void abort(void);
+}
+
+int main()
+{
+ A c = f();
+
+ if (rvalue_constructions != 0)
+ abort();
+}
OpenPOWER on IntegriCloud