summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/null-cast.cpp
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2017-05-26 02:16:00 +0000
committerTim Northover <tnorthover@apple.com>2017-05-26 02:16:00 +0000
commit0150333a3c565fec97d4d65302abbb15ed21ecc4 (patch)
tree88f48feb73042fa360b5e1c95f429cc519afbe6d /clang/test/SemaCXX/null-cast.cpp
parenteb04c8cae2f0867c3959285a992f5319b8d6cfc7 (diff)
downloadbcm5719-llvm-0150333a3c565fec97d4d65302abbb15ed21ecc4.tar.gz
bcm5719-llvm-0150333a3c565fec97d4d65302abbb15ed21ecc4.zip
Create valid LValue to represent null pointers in constant exprs
We were leaving the SubobjectDesignator in a surprising situation, where it was allegedly valid but didn't actually refer to a type. This caused a crash later on. This patch fills out the SubobjectDesignator with the pointee type (as happens in other evaluations of constant pointers) so that we don't crash later. llvm-svn: 303957
Diffstat (limited to 'clang/test/SemaCXX/null-cast.cpp')
-rw-r--r--clang/test/SemaCXX/null-cast.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/null-cast.cpp b/clang/test/SemaCXX/null-cast.cpp
new file mode 100644
index 00000000000..c80ab8fced1
--- /dev/null
+++ b/clang/test/SemaCXX/null-cast.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {};
+struct B : virtual A {};
+
+void foo() {
+ (void)static_cast<A&>(*(B *)0); // expected-warning {{binding dereferenced null pointer to reference has undefined behavior}}
+}
OpenPOWER on IntegriCloud