xref: /llvm-project/clang/test/SemaCXX/offsetof.cpp (revision 78cde14444cb462f8f7787090c957c61b8c2aff6)
1 // RUN: clang-cc -fsyntax-only -verify %s -Winvalid-offsetof
2 
3 struct NonPOD {
4   virtual void f();
5   int m;
6 };
7 
8 struct P {
9   NonPOD fieldThatPointsToANonPODType;
10 };
11 
12 void f() {
13   int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-POD type 'struct P'}}
14 }
15 
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}}
19