repo.or.cz
/
netbsd-mini2440.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
No empty .Rs/.Re
[netbsd-mini2440.git]
/
gnu
/
dist
/
gcc4
/
gcc
/
testsuite
/
g++.dg
/
tree-ssa
/
pr17400.C
blob
a6619a84fd3f772435c35c06e70bce1f394115db
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
}