projects
/
gcc.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
re PR tree-optimization/33593 (tree-outof-ssa moves sources of non-call exceptions...
[gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
tree-ssa
/
pr17400.C
1
// Test PR 17400. Test case provided by Serge Belyshev.
2
3
/* { dg-do compile } */
4
/* { dg-options "-O1" } */
5
6
7
void inc (int &);
8
bool dec_test (int &);
9
10
struct A
11
{
12
int c;
13
14
friend void AddRef (A * p)
15
{
16
inc (p->c);
17
}
18
19
friend void Release (A * p)
20
{
21
if(dec_test (p->c))
22
delete p;
23
}
24
};
25
26
struct B
27
{
28
B (A *p) : obj(p)
29
{
30
AddRef (obj);
31
}
32
33
~B()
34
{
35
Release (obj);
36
}
37
38
void swap (B &rhs)
39
{
40
A * tmp = obj;
41
obj = rhs.obj;
42
rhs.obj = tmp;
43
}
44
45
A *obj;
46
};
47
48
void bar (A *p1, A* p2)
49
{
50
B px (p1);
51
B px2 (p2);
52
px.swap (px2);
53
}