summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-13 20:40:44 +0000
committeramacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-13 20:40:44 +0000
commit2b854ca0daffeb935158802df37aa7ca147dc00d (patch)
treed1e7c9d2ede0efe840f29c7783523a1dc3c5dd1a
parente64e1ea15adfb8f98a4ea44c2e000b6d92fe60f5 (diff)
downloadgcc-2b854ca0daffeb935158802df37aa7ca147dc00d.tar.gz
2004-09-13 Andrew MacLeod <amacleod@redhat.com>
* g++.dg/tree-ssa/pr17400.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87449 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr17400.C53
2 files changed, 57 insertions, 0 deletions
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 <amacleod@redhat.com>
+
+ * g++.dg/tree-ssa/pr17400.C: New testcase.
+
2004-09-13 James E Wilson <wilson@specifixinc.com>
* 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);
+}