| 1 |
// { dg-do run } |
| 2 |
// { dg-options "-w" } |
| 3 |
// Origin: Mark Mitchell <[email protected]> |
| 4 |
|
| 5 |
#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 |
| 6 |
|
| 7 |
struct S0 |
| 8 |
{ |
| 9 |
}; |
| 10 |
|
| 11 |
struct S1 : public S0 |
| 12 |
{ |
| 13 |
}; |
| 14 |
|
| 15 |
struct S2 : public S1 |
| 16 |
{ |
| 17 |
char c; |
| 18 |
}; |
| 19 |
|
| 20 |
// In S3, the S1 instance is allocated first at offset zero. The S2 |
| 21 |
// instance has to be allocated at a subsequent offset; it's first |
| 22 |
// part is also an S1. |
| 23 |
|
| 24 |
struct S3 : public S1, public S2 |
| 25 |
{ |
| 26 |
}; |
| 27 |
|
| 28 |
struct S4 |
| 29 |
{ |
| 30 |
int i; |
| 31 |
}; |
| 32 |
|
| 33 |
// In S4, in contrast to S3, S2 is allocated first, and S1 can be |
| 34 |
// allocated on top of S4. |
| 35 |
|
| 36 |
struct S5 : public S2, public S1, public S4 |
| 37 |
{ |
| 38 |
}; |
| 39 |
|
| 40 |
// The T classes are by-hand layouts that should be equivalent to the |
| 41 |
// S classes. |
| 42 |
|
| 43 |
struct T3 |
| 44 |
{ |
| 45 |
S1 s1; |
| 46 |
S2 s2; |
| 47 |
}; |
| 48 |
|
| 49 |
struct T5 |
| 50 |
{ |
| 51 |
S2 s2; |
| 52 |
S4 s4; |
| 53 |
}; |
| 54 |
|
| 55 |
int main () |
| 56 |
{ |
| 57 |
if (sizeof (S3) != sizeof (T3)) |
| 58 |
return 1; |
| 59 |
else if (sizeof (S5) != sizeof (T5)) |
| 60 |
return 2; |
| 61 |
} |
| 62 |
|
| 63 |
#else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ |
| 64 |
|
| 65 |
int main () |
| 66 |
{ |
| 67 |
} |
| 68 |
|
| 69 |
#endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ |