xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/offsetof-0x.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc struct NonPOD {
4*f4a2713aSLionel Sambuc   virtual void f();
5*f4a2713aSLionel Sambuc   int m;
6*f4a2713aSLionel Sambuc };
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc struct P {
9*f4a2713aSLionel Sambuc   NonPOD fieldThatPointsToANonPODType;
10*f4a2713aSLionel Sambuc };
11*f4a2713aSLionel Sambuc 
f()12*f4a2713aSLionel Sambuc void f() {
13*f4a2713aSLionel Sambuc   int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-standard-layout type 'P'}}
14*f4a2713aSLionel Sambuc }
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc struct StandardLayout {
17*f4a2713aSLionel Sambuc   int x;
StandardLayoutStandardLayout18*f4a2713aSLionel Sambuc   StandardLayout() {}
19*f4a2713aSLionel Sambuc };
20*f4a2713aSLionel Sambuc int o = __builtin_offsetof(StandardLayout, x); // no-warning
21