summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.eh/catch11.C
blob: 275a96ac7795c20360186c555faa610fb8f18d32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// { dg-do run  }
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 24 May 2000 <nathan@codesourcery.com>

// we should be able to catch a base a virtual, provided it is accessible by at
// least one public path
// -- public, << private, == virtual
// E<<B==A
// +--C==A
// +<<D==A

struct A {};
struct B : virtual A {};
struct C : virtual A {};
struct D : virtual A {};
struct E : private B, public C, private D {};

extern "C" void abort ();

void fne (E *e)
{
  throw e;
}

void check(E *e)
{
  int caught;
  
  caught = 0;
  try { fne(e); }
  catch(A *p) { caught = 1; if (p != e) abort();}
  catch(...) { abort(); }
  if (!caught) abort();

  caught = 0;
  try { fne(e); }
  catch(B *p) { abort ();}
  catch(...) { caught = 1; }
  if (!caught) abort();

  caught = 0;
  try { fne(e); }
  catch(C *p) { caught = 1; if (p != e) abort();}
  catch(...) { abort(); }
  if (!caught) abort();

  caught = 0;
  try { fne(e); }
  catch(D *p) { abort ();}
  catch(...) { caught = 1; }
  if (!caught) abort();

  return;
}

int main ()
{
  E e;
  
  check (&e);
  check ((E *)0);

  return 0;
}