21 lines · cpp
1// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,osx -verify -fblocks %s2// expected-no-diagnostics3 4// Test handling of OSAtomicCompareAndSwap when C++ inserts "no-op" casts and we5// do a forced load and binding to the environment on an expression that would regularly6// not have an environment binding. This previously triggered a crash.7// NOTE: It is critical that the function called is OSAtomicCompareAndSwapIntBarrier.8bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue ) ;9static int _rdar9339920_x = 0;10int rdar9339920_aux();11 12int 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