mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 15:36:49 +00:00

Before: ``` offset of on non-POD type ``` After: ``` offsetof on non-POD type ``` --------- Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
22 lines
624 B
C++
22 lines
624 B
C++
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof -fexperimental-new-constant-interpreter
|
|
|
|
struct NonPOD {
|
|
virtual void f();
|
|
int m;
|
|
};
|
|
|
|
struct P {
|
|
NonPOD fieldThatPointsToANonPODType;
|
|
};
|
|
|
|
void f() {
|
|
int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{'offsetof' on non-standard-layout type 'P'}}
|
|
}
|
|
|
|
struct StandardLayout {
|
|
int x;
|
|
StandardLayout() {}
|
|
};
|
|
int o = __builtin_offsetof(StandardLayout, x); // no-warning
|