1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof
9 NonPOD fieldThatPointsToANonPODType;
13 int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-POD type 'P'}}
16 struct Base { int x; };
17 struct Derived : Base { int y; };
18 int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on non-POD type}}
20 const int o2 = sizeof(__builtin_offsetof(Derived, x));
26 // Constant and non-constant offsetof expressions
27 void test_ice(int i) {
28 int array0[__builtin_offsetof(HasArray, array[5])];
29 int array1[__builtin_offsetof(HasArray, array[i])];
33 struct has_bitfields {
35 int j : 12; // expected-note{{bit-field is declared here}}
38 int test3 = __builtin_offsetof(struct has_bitfields, j); // expected-error{{cannot compute offset of bit-field 'j'}}
40 // offsetof referring to members of a base class.
49 struct Derived2 : public Base1, public Base2 {
53 int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1];
54 int derived2[__builtin_offsetof(Derived2, y) == 4? 1 : -1];
55 int derived3[__builtin_offsetof(Derived2, z) == 8? 1 : -1];
57 // offsetof referring to anonymous struct in base.
65 struct bar : public foo {
68 int anonstruct[__builtin_offsetof(bar, x) == 0 ? 1 : -1];
74 int ltor = __builtin_offsetof(struct LtoRCheck, a[LtoRCheck().f]); // \
75 expected-error {{reference to non-static member function must be called}}