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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [eh/] [scope1.C] - Blame information for rev 801

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

Line No. Rev Author Line
1 693 jeremybenn
// Test that we've scoped the destructor properly for variables declared
2
// in a conditional.
3
// { dg-do run }
4
 
5
extern "C" void abort ();
6
 
7
class C
8
{
9
  bool live;
10
 public:
11
  C();
12
  C(const C &);
13
  ~C ();
14
  operator bool() const;
15
};
16
 
17
void f1 ()
18
{
19
  while (C br = C()) abort ();
20
}
21
 
22
void f2 ()
23
{
24
  for (; C br = C(); ) abort ();
25
}
26
 
27
void f3 ()
28
{
29
  if (C br = C()) abort ();
30
}
31
 
32
void f4 ()
33
{
34
  switch (C br = C())
35
    {
36
    default:
37
      abort ();
38
    case false:
39
      break;
40
    }
41
}
42
 
43
int main()
44
{
45
  f1(); f2(); f3(); f4();
46
  return 0;
47
}
48
 
49
C::C()
50
{
51
  live = true;
52
}
53
 
54
C::C(const C &o)
55
{
56
  if (!o.live)
57
    abort ();
58
  live = true;
59
}
60
 
61
C::~C()
62
{
63
  live = false;
64
}
65
 
66
C::operator bool() const
67
{
68
  if (!live)
69
    abort ();
70
  return false;
71
}

powered by: WebSVN 2.1.0

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