summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/offsetof.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-10-15 06:28:23 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-10-15 06:28:23 +0000
commitff17f8367311f61d3c9246a76bfd8102f148f575 (patch)
tree489b284269e41995043ffd08d16c3af67b69d059 /clang/test/SemaCXX/offsetof.cpp
parentda2f405b0903ae21577b877ec49892e28eff0d0d (diff)
downloadbcm5719-llvm-ff17f8367311f61d3c9246a76bfd8102f148f575.tar.gz
bcm5719-llvm-ff17f8367311f61d3c9246a76bfd8102f148f575.zip
Sema: Consider it an error to apply __builtin_offsetof to a member in a virtual base
icc 13 and g++ 4.9 both reject this while we would crash. Fixes PR17578. llvm-svn: 192674
Diffstat (limited to 'clang/test/SemaCXX/offsetof.cpp')
-rw-r--r--clang/test/SemaCXX/offsetof.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/offsetof.cpp b/clang/test/SemaCXX/offsetof.cpp
index a5f5d347c28..e6069ac9c0a 100644
--- a/clang/test/SemaCXX/offsetof.cpp
+++ b/clang/test/SemaCXX/offsetof.cpp
@@ -73,3 +73,13 @@ struct LtoRCheck {
};
int ltor = __builtin_offsetof(struct LtoRCheck, a[LtoRCheck().f]); // \
expected-error {{reference to non-static member function must be called}}
+
+namespace PR17578 {
+struct Base {
+ int Field;
+};
+struct Derived : virtual Base {
+ void Fun() { (void)__builtin_offsetof(Derived, Field); } // expected-warning {{offset of on non-POD type}} \
+ expected-error {{invalid application of 'offsetof' to a field of a virtual base}}
+};
+}
OpenPOWER on IntegriCloud