summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/casts.cpp
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2018-05-04 21:39:25 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2018-05-04 21:39:25 +0000
commit2fd6aa7d5603e13aaea80bcb391c04a8e1014b13 (patch)
treea33c161276109616a28ec69679d2f5c0cf50b0a7 /clang/test/Analysis/casts.cpp
parent5b39acd111e082e2ba91eb83de7ecb9763f76115 (diff)
downloadbcm5719-llvm-2fd6aa7d5603e13aaea80bcb391c04a8e1014b13.tar.gz
bcm5719-llvm-2fd6aa7d5603e13aaea80bcb391c04a8e1014b13.zip
[analyzer] pr37209: Fix casts of glvalues to references.
Many glvalue expressions aren't of their respective reference type - they are simply glvalues of their value type. This was causing problems when we were trying to obtain type of the original expression while evaluating certain glvalue bit-casts. Fixed by artificially forging a reference type to provide to the casting procedure. Differential Revision: https://reviews.llvm.org/D46224 llvm-svn: 331558
Diffstat (limited to 'clang/test/Analysis/casts.cpp')
-rw-r--r--clang/test/Analysis/casts.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/Analysis/casts.cpp b/clang/test/Analysis/casts.cpp
index f96f19b0ac3..6499b20a79d 100644
--- a/clang/test/Analysis/casts.cpp
+++ b/clang/test/Analysis/casts.cpp
@@ -21,3 +21,17 @@ void intAsBoolAsSwitchCondition(int c) {
break;
}
}
+
+int *&castToIntPtrLValueRef(char *p) {
+ return (int *&)*(int *)p;
+}
+bool testCastToIntPtrLValueRef(char *p, int *s) {
+ return castToIntPtrLValueRef(p) != s; // no-crash
+}
+
+int *&&castToIntPtrRValueRef(char *p) {
+ return (int *&&)*(int *)p;
+}
+bool testCastToIntPtrRValueRef(char *p, int *s) {
+ return castToIntPtrRValueRef(p) != s; // no-crash
+}
OpenPOWER on IntegriCloud