2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -Winvalid-offsetof
|
2009-05-02 07:20:30 +08:00
|
|
|
|
|
|
|
struct NonPOD {
|
|
|
|
virtual void f();
|
|
|
|
int m;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct P {
|
|
|
|
NonPOD fieldThatPointsToANonPODType;
|
|
|
|
};
|
|
|
|
|
|
|
|
void f() {
|
2009-05-03 01:45:47 +08:00
|
|
|
int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-POD type 'struct P'}}
|
2009-05-02 07:20:30 +08:00
|
|
|
}
|
|
|
|
|
2009-12-04 15:18:51 +08:00
|
|
|
struct Base { int x; };
|
|
|
|
struct Derived : Base { int y; };
|
|
|
|
int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on non-POD type}}
|
2009-12-12 15:25:49 +08:00
|
|
|
|
|
|
|
const int o2 = sizeof(__builtin_offsetof(Derived, x));
|