2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / other / offsetof9.C
blobbd80fa5e2cf0663f3a2a501d50e6fddae31c5995
1 // PR c++/68727
2 // { dg-do compile }
3 // { dg-options "-Winvalid-offsetof" }
5 struct A { int i; };
6 struct B : virtual A { };
7 __SIZE_TYPE__ s = __builtin_offsetof (B, A::i); // { dg-warning "offsetof within non-standard-layout type" }
9 template <typename T>
10 __SIZE_TYPE__
11 foo ()
13   return __builtin_offsetof (T, A::i)           // { dg-warning "offsetof within non-standard-layout type" }
14          + __builtin_offsetof (B, A::i);        // { dg-warning "offsetof within non-standard-layout type" }
17 __SIZE_TYPE__ t = foo<B> ();