aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.oliva/thunk1.C
blob: 5407e9e058341d9d121e969e767cd94f7f26c104 (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
// Copyright (C) 1999 Free Software Foundation

// by Alexandre Oliva <oliva@dcc.unicamp.br>
// based on bug report by Fredrik Öhrström <d92-foh@nada.kth.se>

// Special g++ Options: -fvtable-thunks
// execution test - XFAIL *-*-*

#include <cstdlib>

using namespace std;

struct vbase {
  virtual int get_a() const = 0;
};

struct base: virtual vbase {
  int a;
  base(int aa) : a(aa) {}
  int get_a() const { return a; }
};

struct mid: base {
  mid(int bb) : base(bb) {
    // when mid is not in charge of vbase initialization,
    // a derived-aware vtable is needed for vbase
    if (((vbase*)this)->get_a() != bb)
      abort();
  }
};

struct derived: virtual mid {
  derived(int cc) : mid(cc) {}
};

int main () {
  derived(1);
}