Debian Codegraph @

gcc/testsuite/g++.dg/opt/thunk1.C

raw
1 // PR 6788
2 // Test that the thunk adjusts the this pointer properly.
3 // { dg-do run }
4 // { dg-require-effective-target size20plus }
5
6 extern "C" void abort ();
7
8 struct A
9 {
10 virtual void foo() = 0;
11 char large[33*1024U];
12 };
13
14 struct B
15 {
16 virtual void foo() = 0;
17 };
18
19 struct C : public A, public B
20 {
21 virtual void foo();
22 };
23
24 static C *match;
25
26 void C::foo()
27 {
28 if (this != match)
29 abort ();
30 }
31
32 void bar(B *x)
33 {
34 x->foo();
35 }
36
37 int main()
38 {
39 C obj;
40 match = &obj;
41 bar(&obj);
42 return 0;
43 }