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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.eh/] [catch4p.C] - Blame information for rev 699

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do run  }
2
// { dg-options "-w" }
3
// Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4
// Contributed by Nathan Sidwell 29 Aug 1999 
5
 
6
// We cannot catch an ambiguous base class. Check with a virtual
7
// polymorphic public DAG.
8
// -- public, << private, == virtual
9
 
10
// D--B==A
11
// +--C==A
12
 
13
 
14
struct A { int m; virtual ~A(){}};
15
struct B : virtual A { int m; };
16
struct C : virtual A { int m; };
17
struct D : B, C { int m; };
18
 
19
void fna(A *obj) { throw obj; }
20
void fnb(B *obj) { throw obj; }
21
void fnc(C *obj) { throw obj; }
22
void fnd(D *obj) { throw obj; }
23
 
24
extern "C" void abort();
25
 
26
void check(D *d)
27
{
28
  int caught;
29
 
30
  // try with whole object
31
  caught = 0;
32
  try { fnd(d); }
33
  catch(A *p) { caught = 1; if (p != d) abort();}
34
  catch(...) { abort(); }
35
  if (!caught) abort();
36
 
37
  caught = 0;
38
  try { fnd(d); }
39
  catch(B *p) { caught = 1; if (p != d) abort();}
40
  catch(...) { abort(); }
41
  if (!caught) abort();
42
 
43
  caught = 0;
44
  try { fnd(d); }
45
  catch(C *p) { caught = 1; if (p != d) abort();}
46
  catch(...) { abort(); }
47
  if (!caught) abort();
48
 
49
  // try with an A object
50
  caught = 0;
51
  try { fna((B *)d); }
52
  catch(B *p) { abort(); } // throw type is static type
53
  catch(A *p) { caught = 1; if (p != d) abort();}
54
  catch(...) { abort(); }
55
  if (!caught) abort();
56
 
57
  caught = 0;
58
  try { fna((C *)d); }
59
  catch(C *p) { abort(); } // throw type is static type
60
  catch(A *p) { caught = 1; if (p != d) abort();}
61
  catch(...) { abort(); }
62
  if (!caught) abort();
63
 
64
  // try with B object
65
  caught = 0;
66
  try { fnb((B *)d); }
67
  catch(A *p) { caught = 1; if (p != d) abort();}
68
  catch(...) { abort(); }
69
  if (!caught) abort();
70
 
71
  caught = 0;
72
  try { fnb((B *)d); }
73
  catch(B *p) { caught = 1; if (p != d) abort();}
74
  catch(...) { abort(); }
75
  if (!caught) abort();
76
 
77
  caught = 0;
78
  try { fnb((B *)d); }
79
  catch(C *p) { abort(); }
80
  catch(D *p) { abort(); }
81
  catch(...) { caught =1; }
82
  if (!caught) abort();
83
 
84
  // try with C object
85
  caught = 0;
86
  try { fnc((C *)d); }
87
  catch(A *p) { caught = 1; if (p != d) abort();}
88
  catch(...) { abort(); }
89
  if (!caught) abort();
90
 
91
  caught = 0;
92
  try { fnc((C *)d); }
93
  catch(C *p) { caught = 1; if (p != d) abort();}
94
  catch(...) { abort(); }
95
  if (!caught) abort();
96
 
97
  caught = 0;
98
  try { fnc((C *)d); }
99
  catch(B *p) { abort(); }
100
  catch(D *p) { abort(); }
101
  catch(...) { caught =1; }
102
  if (!caught) abort();
103
 
104
  return;
105
}
106
 
107
int main ()
108
{
109
  D d;
110
  check (&d); // try with an object
111
  check ((D *)0); // try with no object
112
 
113
  return 0;
114
}

powered by: WebSVN 2.1.0

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