OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [tree-ssa/] [pr17400.C] - Blame information for rev 717

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// 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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.