1 // { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } }
2 
3 #define ATTR0 __attribute__((__regparm__(0)))
4 #define ATTR1 __attribute__((__regparm__(1)))
5 #define ATTR2 __attribute__((__regparm__(2)))
6 #define ATTR3 __attribute__((__regparm__(3)))
7 #define ATTR4 __attribute__((__fastcall__))
8 #define ATTR5 __attribute__((__stdcall__))
9 #define ATTR6 __attribute__((__cdecl__))
10 #define ATTR7
11 #define ATTR8 __attribute__((__thiscall__))
12 
13 extern "C" void abort (void);
14 
15 struct long_struct
16 {
17   int a[3];
18 };
19 
20 struct long_struct ret;
21 
22 class c3 *this3;
23 
24 class c1
25 {
26   int val1;
27 public:
foo()28     virtual void foo () { }
29 };
30 
31 class c2
32 {
33 public:
method0()34   virtual ATTR0 struct long_struct method0 ()
35   {
36     return ret;
37   }
38 
method1()39   virtual ATTR1 struct long_struct method1 ()
40   {
41     return ret;
42   }
43 
method2()44   virtual ATTR2 struct long_struct method2 ()
45   {
46     return ret;
47   }
48 
method3()49   virtual ATTR3 struct long_struct method3 ()
50   {
51     return ret;
52   }
53 
method4()54   virtual ATTR4 struct long_struct method4 ()
55   {
56     return ret;
57   }
58 
method5()59   virtual ATTR5 struct long_struct method5 ()
60   {
61     return ret;
62   }
63 
method6()64   virtual ATTR6 struct long_struct method6 ()
65   {
66     return ret;
67   }
68 
method7()69   virtual ATTR7 struct long_struct method7 ()
70   {
71     return ret;
72   }
73 
method8()74   virtual ATTR8 struct long_struct method8 ()
75   {
76     return ret;
77   }
78 };
79 
80 class c3:c1, public c2
81 {
82 public:
c3()83   c3 ()
84   {
85     this3 = this;
86   }
87 
check_this(int a)88   struct long_struct check_this (int a)
89   {
90     if (this3 != this)
91       abort ();
92 
93     return ret;
94   }
95 
method0()96   virtual ATTR0 struct long_struct method0 ()
97   {
98     return check_this (0);
99   }
100 
method1()101   virtual ATTR1 struct long_struct method1 ()
102   {
103     return check_this (1);
104   }
105 
method2()106   virtual ATTR2 struct long_struct method2 ()
107   {
108     return check_this (2);
109   }
110 
method3()111   virtual ATTR3 struct long_struct method3 ()
112   {
113     return check_this (3);
114   }
115 
method4()116   virtual ATTR4 struct long_struct method4 ()
117   {
118     return check_this (4);
119   }
120 
method5()121   virtual ATTR5 struct long_struct method5 ()
122   {
123     return check_this (5);
124   }
125 
method6()126   virtual ATTR6 struct long_struct method6 ()
127   {
128     return check_this (6);
129   }
130 
method7()131   virtual ATTR7 struct long_struct method7 ()
132   {
133     return check_this (7);
134   }
135 
method8()136   virtual ATTR8 struct long_struct method8 ()
137   {
138     return check_this (7);
139   }
140 };
141 
142 class c3 c3_instance;
143 class c2 *c2_ptr = &c3_instance;
144 
145 int
main()146 main ()
147 {
148   c2_ptr->method0 ();
149   c2_ptr->method1 ();
150   c2_ptr->method2 ();
151   c2_ptr->method3 ();
152   c2_ptr->method4 ();
153   c2_ptr->method5 ();
154   c2_ptr->method6 ();
155   c2_ptr->method7 ();
156   c2_ptr->method8 ();
157 
158   return 0;
159 }
160