blob: 3283270847fda080a3727906ed7433c261411144 [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -Winvalid-offsetof
Anders Carlsson2bbb86b2009-05-01 23:20:30 +00002
3struct NonPOD {
4 virtual void f();
5 int m;
6};
7
8struct P {
9 NonPOD fieldThatPointsToANonPODType;
10};
11
12void f() {
John McCall85f90552010-03-10 11:27:22 +000013 int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-POD type 'P'}}
Anders Carlsson2bbb86b2009-05-01 23:20:30 +000014}
15
Eli Friedman78cde142009-12-04 07:18:51 +000016struct Base { int x; };
17struct Derived : Base { int y; };
18int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on non-POD type}}
Douglas Gregor7ca84af2009-12-12 07:25:49 +000019
20const int o2 = sizeof(__builtin_offsetof(Derived, x));