]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/g++.old-deja/g++.jason/thunk3.C
Commit of nios2 port to trunk:
[thirdparty/gcc.git] / gcc / testsuite / g++.old-deja / g++.jason / thunk3.C
1 // { dg-do run }
2 // { dg-skip-if "fails with generic thunk support" { rs6000-*-* powerpc-*-eabi v850-*-* sh-*-* sh64-*-* h8*-*-* xtensa*-*-* m32r*-*-* lm32-*-* nios2-*-* } { "*" } { "" } }
3 // Test that variadic function calls using thunks work right.
4 // Note that this will break on any target that uses the generic thunk
5 // support, because it doesn't support variadic functions.
6
7
8 #include <stdarg.h>
9
10 struct A {
11 void* p;
12 A (void* q): p (q) { }
13 A (const A& a): p (a.p) { }
14 };
15
16 class CBase {
17 public:
18 virtual void BaseFunc();
19 };
20
21 class MMixin {
22 public:
23 virtual A MixinFunc(int arg, ...) = 0;
24 };
25
26 class CExample : public CBase, public MMixin {
27 public:
28 A MixinFunc(int arg, ...);
29 };
30
31 void CBase::BaseFunc()
32 {
33 }
34
35 A CExample::MixinFunc(int arg, ...)
36 {
37 va_list ap;
38 va_start (ap, arg);
39
40 if (arg != 1 || va_arg (ap, int) != 2 || va_arg (ap, int) != 3
41 || va_arg (ap, int) != 4 || va_arg (ap, int) != 5
42 || va_arg (ap, int) != 6 || va_arg (ap, int) != 7
43 || va_arg (ap, int) != 8 || va_arg (ap, int) != 9)
44 return 0;
45 return this;
46 }
47
48 void* test(MMixin& anExample)
49 {
50 return anExample.MixinFunc(1,2,3,4,5,6,7,8,9).p;
51 }
52
53 int main ()
54 {
55 CExample c;
56
57 if (test(c) != &c)
58 return 1;
59 }