misc-ps.m revision 76dba7b67a36b2d6311e4ad4714df5dbd39dbebe
1// RUN: clang -checker-cfref --verify %s
2
3// Reduced test case from crash in <rdar://problem/6253157>
4@class NSObject;
5@interface A @end
6@implementation A
7- (void)foo:(void (^)(NSObject *x))block {
8  if (!((block != ((void *)0)))) {}
9}
10@end
11
12// Reduced test case from crash in PR 2796;
13//  http://llvm.org/bugs/show_bug.cgi?id=2796
14
15unsigned foo(unsigned x) { return __alignof__((x)) + sizeof(x); }
16
17// Improvement to path-sensitivity involving compound assignments.
18//  Addresses false positive in <rdar://problem/6268365>
19//
20
21unsigned r6268365Aux();
22
23void r6268365() {
24  unsigned x = 0;
25  x &= r6268365Aux();
26  unsigned j = 0;
27    
28  if (x == 0) ++j;
29  if (x == 0) x = x / j; // no-warning
30}
31
32void divzeroassume(unsigned x, unsigned j) {  
33  x /= j;  
34  if (j == 0) x /= 0;     // no-warning
35  if (j == 0) x /= j;     // no-warning
36  if (j == 0) x = x / 0;  // no-warning
37}
38
39void divzeroassumeB(unsigned x, unsigned j) {  
40  x = x / j;  
41  if (j == 0) x /= 0;     // no-warning
42  if (j == 0) x /= j;     // no-warning
43  if (j == 0) x = x / 0;  // no-warning
44}
45
46// PR 2948 (testcase; crash on VisitLValue for union types)
47// http://llvm.org/bugs/show_bug.cgi?id=2948
48
49void checkaccess_union() {
50  int ret = 0, status;
51  if (((((__extension__ (((union {
52    __typeof (status) __in; int __i;}
53    )
54    {
55      .__in = (status)}
56      ).__i))) & 0xff00) >> 8) == 1)
57        ret = 1;
58}
59
60// InitListExpr processing
61
62typedef float __m128 __attribute__((__vector_size__(16), __may_alias__));
63__m128 return128() {
64  return __extension__(__m128) { 0.0f, 0.0f, 0.0f, 0.0f };
65}
66
67