summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/offsetof-0x.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/offsetof-0x.cpp')
-rw-r--r--test/SemaCXX/offsetof-0x.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/SemaCXX/offsetof-0x.cpp b/test/SemaCXX/offsetof-0x.cpp
new file mode 100644
index 0000000..610d919
--- /dev/null
+++ b/test/SemaCXX/offsetof-0x.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof
+
+struct NonPOD {
+ virtual void f();
+ int m;
+};
+
+struct P {
+ NonPOD fieldThatPointsToANonPODType;
+};
+
+void f() {
+ int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-standard-layout type 'P'}}
+}
+
+struct StandardLayout {
+ int x;
+ StandardLayout() {}
+};
+int o = __builtin_offsetof(StandardLayout, x); // no-warning
OpenPOWER on IntegriCloud