Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.jason/thunk2.C

raw
1 // { dg-do run { target fpic } }
2 // { dg-options "-fPIC" }
3 // Test that non-variadic function calls using thunks and PIC work right.
4
5 struct A {
6 void* p;
7 A (void* q): p (q) { }
8 A (const A& a): p (a.p) { }
9 };
10
11 class CBase {
12 public:
13 virtual void BaseFunc();
14 };
15
16 class MMixin {
17 public:
18 virtual A MixinFunc(int arg, A arg2) = 0;
19 };
20
21 class CExample : public CBase, public MMixin {
22 public:
23 A MixinFunc(int arg, A arg2);
24 };
25
26 void CBase::BaseFunc()
27 {
28 }
29
30 A CExample::MixinFunc(int arg, A arg2)
31 {
32 if (arg != 1 || arg2.p != 0)
33 return 0;
34 return this;
35 }
36
37 void* test(MMixin& anExample)
38 {
39 return anExample.MixinFunc(1,A(0)).p;
40 }
41
42 int
43 main ()
44 {
45 CExample c;
46
47 if (test(c) != &c)
48 return 1;
49
50 return 0;
51 }