• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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 
3 // Test handling of OSAtomicCompareAndSwap when C++ inserts "no-op" casts and we
4 // do a forced load and binding to the environment on an expression that would regularly
5 // not have an environment binding.  This previously triggered a crash (<rdar://problem/9339920>).
6 // NOTE: It is critical that the function called is OSAtomicCompareAndSwapIntBarrier.
7 bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue ) ;
8 static int _rdar9339920_x = 0;
9 int rdar9339920_aux();
10 
rdar9339920_test()11 int rdar9339920_test() {
12   int rdar9339920_x = rdar9339920_aux();
13   if (rdar9339920_x != _rdar9339920_x) {
14     if (OSAtomicCompareAndSwapIntBarrier(_rdar9339920_x, rdar9339920_x, &_rdar9339920_x))
15       return 1;
16   }
17   return 0;
18 }
19 
20