summaryrefslogtreecommitdiff
path: root/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
commitb535f9fe7ca65ae3028391188bd228c0cc38eeb6 (patch)
treeb61f4ef7d58df2bad1733742823899ddfa3486c8 /test/SemaCXX/null-cast.cpp
parentbc7fbfa106a523b15654c40e21fca1475339fad8 (diff)
downloadclang-b535f9fe7ca65ae3028391188bd228c0cc38eeb6.tar.gz
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303957 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/null-cast.cpp')
-rw-r--r--test/SemaCXX/null-cast.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/SemaCXX/null-cast.cpp b/test/SemaCXX/null-cast.cpp
new file mode 100644
index 0000000000..c80ab8fced
--- /dev/null
+++ b/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}}
+}