OSDN Git Service

* g++.old-deja/g++.benjamin/p12475.C: Use LONG_MAX to find
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.jason / thunk3.C
1 // Test that variadic function calls using thunks work right.
2 // Note that this will break on any target that uses the generic thunk
3 //  support, because it doesn't support variadic functions.
4
5 // Special g++ Options: -fvtable-thunks
6 // excess errors test - XFAIL mips*-*-* rs6000-*-* powerpc-*-eabi m68k-*-coff m68k-motorola-sysv m88k-motorola-sysv3
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    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 main ()
54 {
55   CExample c;
56
57   if (test(c) != &c)
58     return 1;
59 }