aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/rvo.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/cpp0x/rvo.C')
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/cpp0x/rvo.C24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/rvo.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/rvo.C
new file mode 100644
index 000000000..fc83b1b56
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/rvo.C
@@ -0,0 +1,24 @@
+// { dg-do run { target c++11 } }
+// 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();
+}