diff options
-rw-r--r-- | test/Analysis/misc-ps-basic-store.m | 21 | ||||
-rw-r--r-- | test/Analysis/misc-ps-region-store.m | 21 | ||||
-rw-r--r-- | test/Analysis/misc-ps.m | 18 |
3 files changed, 45 insertions, 15 deletions
diff --git a/test/Analysis/misc-ps-basic-store.m b/test/Analysis/misc-ps-basic-store.m new file mode 100644 index 0000000000..8d7ac87b26 --- /dev/null +++ b/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/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m new file mode 100644 index 0000000000..940d277b92 --- /dev/null +++ b/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/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index f9f1bdd451..f221f8b989 100644 --- a/test/Analysis/misc-ps.m +++ b/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__)); |