From: Ted Kremenek Date: Thu, 22 Jan 2009 18:53:15 +0000 (+0000) Subject: The 'misc-ps.m' test case now passes with RegionStore. One case needed to be split... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2dabd42df78e8d379ed0eebbf8d4a7aac86a9b6f;p=clang The 'misc-ps.m' test case now passes with RegionStore. One case needed to be split out into 'misc-ps-basic-store.m' and 'misc-ps-region-store.m' because the behavior was different between the two store models (RegionStore flags an additional valid bug). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62772 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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 @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__));