llvm-project/clang/test/SemaCXX/offsetof-0x.cpp
Michael Buch 0794d5cfba
[clang][Sema] Fix typo in 'offsetof' diagnostics (#133448)
Before:
```
offset of on non-POD type
```
After:
```
offsetof on non-POD type
```

---------

Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2025-03-31 14:56:29 +01:00

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