aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/reference.cpp
diff options
context:
space:
mode:
authorJordy Rose <jediknil@belkadan.com>2010-06-04 01:14:56 +0000
committerJordy Rose <jediknil@belkadan.com>2010-06-04 01:14:56 +0000
commit5d55376106f1aeabfab0bcd7e0167db904409a06 (patch)
tree4cec54e44de92cc20159e4b74325b29aaa05cdf4 /test/Analysis/reference.cpp
parent64fd7e86c1a90d9ff78e4a0bd79f69499667a4e3 (diff)
Assignments to reference variables shouldn't kill the variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105452 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/reference.cpp')
-rw-r--r--test/Analysis/reference.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/Analysis/reference.cpp b/test/Analysis/reference.cpp
index 6b962157da..f1694163a2 100644
--- a/test/Analysis/reference.cpp
+++ b/test/Analysis/reference.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
+typedef typeof(sizeof(int)) size_t;
+void malloc (size_t);
void f1() {
int const &i = 3;
@@ -24,3 +26,31 @@ char t2 () {
*ptr() = 'c';
return '0';
}
+
+// Each of the tests below is repeated with pointers as well as references.
+// This is mostly a sanity check, but then again, both should work!
+char t3 () {
+ char& r = ref();
+ r = 'c'; // no-warning
+ if (r) return r;
+ return *(char*)0; // no-warning
+}
+
+char t4 () {
+ char* p = ptr();
+ *p = 'c'; // no-warning
+ if (*p) return *p;
+ return *(char*)0; // no-warning
+}
+
+char t5 (char& r) {
+ r = 'c'; // no-warning
+ if (r) return r;
+ return *(char*)0; // no-warning
+}
+
+char t6 (char* p) {
+ *p = 'c'; // no-warning
+ if (*p) return *p;
+ return *(char*)0; // no-warning
+}