summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/init
diff options
context:
space:
mode:
authoraaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4>2012-08-31 15:47:29 +0000
committeraaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4>2012-08-31 15:47:29 +0000
commit63ade1d898927dcd4c9544d17bcd44688fb7d6a6 (patch)
tree589f7daabbc93367a0dc703715ace6fc0735ea07 /gcc/testsuite/g++.dg/init
parentf44ba3727388ceb1bb3ed7b1b4bcae6e1438898c (diff)
downloadgcc-63ade1d898927dcd4c9544d17bcd44688fb7d6a6.tar.gz
2012-08-31 Ollie Wild <aaw@google.com>
PR c++/54197 * gcc/cp/call.c (extend_ref_init_temps_1): Handle COMPOUND_EXPR trees. * gcc/testsuite/g++.dg/init/lifetime3.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190834 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg/init')
-rw-r--r--gcc/testsuite/g++.dg/init/lifetime3.C37
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/init/lifetime3.C b/gcc/testsuite/g++.dg/init/lifetime3.C
new file mode 100644
index 00000000000..d099699f868
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/lifetime3.C
@@ -0,0 +1,37 @@
+// PR c++/26714
+// { dg-do run }
+
+extern "C" void abort();
+
+bool ok = false;
+struct A {
+ A() { }
+ ~A() { if (!ok) abort(); }
+};
+
+struct B {
+ static A foo() { return A(); }
+};
+
+B b_g;
+
+struct scoped_ptr {
+ B* operator->() const { return &b_g; }
+ B* get() const { return &b_g; }
+};
+
+B *get() { return &b_g; }
+
+int main()
+{
+ scoped_ptr f;
+ const A& ref1 = f->foo();
+ const A& ref2 = f.get()->foo();
+ const A& ref3 = get()->foo();
+ const A& ref4 = B::foo();
+ B *pf = f.get();
+ const A& ref5 = pf->foo();
+
+
+ ok = true;
+}