summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.other/vtbl2.C
blob: 5c7721e4271fad5c4367931802d9875edf4ab30f (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
65
66
67
68
69
70
71
72
73
74
75
76
77
// { dg-do run  }
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 8 Feb 2000 <nathan@acm.org>

// vtable construction reorganisation broke this

// execution test

#include <stdio.h>

static int fail = 0;

void bad (char const *name)
{
  printf ("Bad %s\n", name);
  fail = 1;
}
void ok (char const *name)
{
  printf ("Ok %s\n", name);
}

struct Core
{
  virtual ~Core ();
  virtual void Wibble () {bad (__PRETTY_FUNCTION__);}
  virtual void Wobble () {bad (__PRETTY_FUNCTION__);}
  virtual void Bogus  () {bad (__PRETTY_FUNCTION__);}
};
struct Side
{
  virtual ~Side ();
  virtual void Arfle () {bad (__PRETTY_FUNCTION__);}
  virtual void Barfle () {bad (__PRETTY_FUNCTION__);}
  virtual void Gloop () {bad (__PRETTY_FUNCTION__);}
  virtual void Glorp () {bad (__PRETTY_FUNCTION__);}
  virtual void Glump () {bad (__PRETTY_FUNCTION__);}
  virtual void Bogus  () {bad (__PRETTY_FUNCTION__);}  
};
struct Base : Core
{
  virtual ~Base ();
  virtual void Bink () {bad (__PRETTY_FUNCTION__);}
  virtual void Bonk () {bad (__PRETTY_FUNCTION__);}
  virtual void  Bogus () {bad (__PRETTY_FUNCTION__);}  
};
struct Multi : Base, Side
{
  virtual ~Multi ();
  virtual void Stomped () {ok (__PRETTY_FUNCTION__);}
  virtual void Bunk () {bad (__PRETTY_FUNCTION__);}
  virtual void Bogus () {bad (__PRETTY_FUNCTION__);}  
};
struct Trail : Multi
{
  virtual ~Trail ();
};
Core::~Core () {}
Side::~Side () {}
Base::~Base () {}
Multi::~Multi () {}
Trail::~Trail () {}

void foo (Multi *ptr)
{
  ptr->Stomped ();
}

int main ()
{
  Multi m;
  Trail t;
  
  foo (&m);
  foo (&t);
  return fail != 0;
}