summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/test/Analysis/misc-ps-basic-store.m21
-rw-r--r--clang/test/Analysis/misc-ps-region-store.m21
-rw-r--r--clang/test/Analysis/misc-ps.m18
3 files changed, 45 insertions, 15 deletions
diff --git a/clang/test/Analysis/misc-ps-basic-store.m b/clang/test/Analysis/misc-ps-basic-store.m
new file mode 100644
index 00000000000..8d7ac87b268
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-basic-store.m
@@ -0,0 +1,21 @@
+// RUN: clang -analyze -checker-cfref --analyzer-store-basic --verify -fblocks %s
+
+//---------------------------------------------------------------------------
+// Test case 'checkaccess_union' differs for region store and basic store.
+// The basic store doesn't reason about compound literals, so the code
+// below won't fire an "uninitialized value" warning.
+//---------------------------------------------------------------------------
+
+// PR 2948 (testcase; crash on VisitLValue for union types)
+// http://llvm.org/bugs/show_bug.cgi?id=2948
+
+void checkaccess_union() {
+ int ret = 0, status;
+ if (((((__extension__ (((union { // no-warning
+ __typeof (status) __in; int __i;}
+ )
+ {
+ .__in = (status)}
+ ).__i))) & 0xff00) >> 8) == 1)
+ ret = 1;
+}
diff --git a/clang/test/Analysis/misc-ps-region-store.m b/clang/test/Analysis/misc-ps-region-store.m
new file mode 100644
index 00000000000..940d277b924
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-region-store.m
@@ -0,0 +1,21 @@
+// RUN: clang -analyze -checker-cfref --analyzer-store-region --verify -fblocks %s
+
+//---------------------------------------------------------------------------
+// Test case 'checkaccess_union' differs for region store and basic store.
+// The basic store doesn't reason about compound literals, so the code
+// below won't fire an "uninitialized value" warning.
+//---------------------------------------------------------------------------
+
+// PR 2948 (testcase; crash on VisitLValue for union types)
+// http://llvm.org/bugs/show_bug.cgi?id=2948
+
+void checkaccess_union() {
+ int ret = 0, status;
+ if (((((__extension__ (((union { // expected-warning {{ Branch condition evaluates to an uninitialized value.}}
+ __typeof (status) __in; int __i;}
+ )
+ {
+ .__in = (status)}
+ ).__i))) & 0xff00) >> 8) == 1)
+ ret = 1;
+}
diff --git a/clang/test/Analysis/misc-ps.m b/clang/test/Analysis/misc-ps.m
index f9f1bdd4513..f221f8b989f 100644
--- a/clang/test/Analysis/misc-ps.m
+++ b/clang/test/Analysis/misc-ps.m
@@ -1,4 +1,6 @@
-// RUN: clang -analyze -checker-cfref --verify -fblocks %s
+// RUN: clang -analyze -checker-cfref --analyzer-store-basic --verify -fblocks %s &&
+// RUN: clang -analyze -checker-cfref --analyzer-store-region --verify -fblocks %s
+
// Reduced test case from crash in <rdar://problem/6253157>
@class NSObject;
@@ -43,20 +45,6 @@ void divzeroassumeB(unsigned x, unsigned j) {
if (j == 0) x = x / 0; // no-warning
}
-// PR 2948 (testcase; crash on VisitLValue for union types)
-// http://llvm.org/bugs/show_bug.cgi?id=2948
-
-void checkaccess_union() {
- int ret = 0, status;
- if (((((__extension__ (((union {
- __typeof (status) __in; int __i;}
- )
- {
- .__in = (status)}
- ).__i))) & 0xff00) >> 8) == 1)
- ret = 1;
-}
-
// InitListExpr processing
typedef float __m128 __attribute__((__vector_size__(16), __may_alias__));
OpenPOWER on IntegriCloud