summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/other/pr35504.C
blob: 58422f24a1494bc258124d86c715e9ee0d63c416 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } }

#define ATTR0 __attribute__((__regparm__(0)))
#define ATTR1 __attribute__((__regparm__(1)))
#define ATTR2 __attribute__((__regparm__(2)))
#define ATTR3 __attribute__((__regparm__(3)))
#define ATTR4 __attribute__((__fastcall__))
#define ATTR5 __attribute__((__stdcall__))
#define ATTR6 __attribute__((__cdecl__))
#define ATTR7
#define ATTR8 __attribute__((__thiscall__))

extern "C" void abort (void);

struct long_struct
{
  int a[3];
};

struct long_struct ret;

class c3 *this3;

class c1
{
  int val1;
public:
    virtual void foo () { }
};

class c2
{
public:
  virtual ATTR0 struct long_struct method0 ()
  {
    return ret;
  }

  virtual ATTR1 struct long_struct method1 ()
  {
    return ret;
  }

  virtual ATTR2 struct long_struct method2 ()
  {
    return ret;
  }

  virtual ATTR3 struct long_struct method3 ()
  {
    return ret;
  }

  virtual ATTR4 struct long_struct method4 ()
  {
    return ret;
  }

  virtual ATTR5 struct long_struct method5 ()
  {
    return ret;
  }

  virtual ATTR6 struct long_struct method6 ()
  {
    return ret;
  }

  virtual ATTR7 struct long_struct method7 ()
  {
    return ret;
  }

  virtual ATTR8 struct long_struct method8 ()
  {
    return ret;
  }
};

class c3:c1, public c2
{
public:
  c3 ()
  {
    this3 = this;
  }

  struct long_struct check_this (int a)
  {
    if (this3 != this)
      abort ();

    return ret;
  }

  virtual ATTR0 struct long_struct method0 ()
  {
    return check_this (0);
  }

  virtual ATTR1 struct long_struct method1 ()
  {
    return check_this (1);
  }

  virtual ATTR2 struct long_struct method2 ()
  {
    return check_this (2);
  }

  virtual ATTR3 struct long_struct method3 ()
  {
    return check_this (3);
  }

  virtual ATTR4 struct long_struct method4 ()
  {
    return check_this (4);
  }

  virtual ATTR5 struct long_struct method5 ()
  {
    return check_this (5);
  }

  virtual ATTR6 struct long_struct method6 ()
  {
    return check_this (6);
  }

  virtual ATTR7 struct long_struct method7 ()
  {
    return check_this (7);
  }

  virtual ATTR8 struct long_struct method8 ()
  {
    return check_this (7);
  }
};

class c3 c3_instance;
class c2 *c2_ptr = &c3_instance;

int
main ()
{
  c2_ptr->method0 ();
  c2_ptr->method1 ();
  c2_ptr->method2 ();
  c2_ptr->method3 ();
  c2_ptr->method4 ();
  c2_ptr->method5 ();
  c2_ptr->method6 ();
  c2_ptr->method7 ();
  c2_ptr->method8 ();

  return 0;
}