blob: 8ad7b3c3da66e2edc45c4bd7da1b49478e05d385 [file] [log] [blame]
Ted Kremenek6b4f5672011-04-27 05:34:09 +00001// 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.
7bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue ) ;
8static int _rdar9339920_x = 0;
9int rdar9339920_aux();
10
11int 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