1*67e74705SXin Li // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,osx -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s 2*67e74705SXin Li // expected-no-diagnostics 3*67e74705SXin Li 4*67e74705SXin Li // Test handling of OSAtomicCompareAndSwap when C++ inserts "no-op" casts and we 5*67e74705SXin Li // do a forced load and binding to the environment on an expression that would regularly 6*67e74705SXin Li // not have an environment binding. This previously triggered a crash (<rdar://problem/9339920>). 7*67e74705SXin Li // NOTE: It is critical that the function called is OSAtomicCompareAndSwapIntBarrier. 8*67e74705SXin Li bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue ) ; 9*67e74705SXin Li static int _rdar9339920_x = 0; 10*67e74705SXin Li int rdar9339920_aux(); 11*67e74705SXin Li rdar9339920_test()12*67e74705SXin Liint rdar9339920_test() { 13*67e74705SXin Li int rdar9339920_x = rdar9339920_aux(); 14*67e74705SXin Li if (rdar9339920_x != _rdar9339920_x) { 15*67e74705SXin Li if (OSAtomicCompareAndSwapIntBarrier(_rdar9339920_x, rdar9339920_x, &_rdar9339920_x)) 16*67e74705SXin Li return 1; 17*67e74705SXin Li } 18*67e74705SXin Li return 0; 19*67e74705SXin Li } 20*67e74705SXin Li 21