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