From: Andrew MacLeod Date: Mon, 13 Sep 2004 20:40:44 +0000 (+0000) Subject: pr17400.C: New testcase. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b4cb0e432b123b1e152e9d35c0675495bde8fe72;p=gcc.git pr17400.C: New testcase. 2004-09-13 Andrew MacLeod * g++.dg/tree-ssa/pr17400.C: New testcase. From-SVN: r87449 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4736e13e528..e4bea8c9b81 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-09-13 Andrew MacLeod + + * g++.dg/tree-ssa/pr17400.C: New testcase. + 2004-09-13 James E Wilson * gcc.target/mips/sb1-1.c: New testcase. diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr17400.C b/gcc/testsuite/g++.dg/tree-ssa/pr17400.C new file mode 100644 index 00000000000..a6619a84fd3 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr17400.C @@ -0,0 +1,53 @@ +// Test PR 17400. Test case provided by Serge Belyshev. + +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + + +void inc (int &); +bool dec_test (int &); + +struct A +{ + int c; + + friend void AddRef (A * p) + { + inc (p->c); + } + + friend void Release (A * p) + { + if(dec_test (p->c)) + delete p; + } +}; + +struct B +{ + B (A *p) : obj(p) + { + AddRef (obj); + } + + ~B() + { + Release (obj); + } + + void swap (B &rhs) + { + A * tmp = obj; + obj = rhs.obj; + rhs.obj = tmp; + } + + A *obj; +}; + +void bar (A *p1, A* p2) +{ + B px (p1); + B px2 (p2); + px.swap (px2); +}