blob: f93895893c59fddf1ebf19d2b87a9dd6fb46170e [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
Andy Gibbs8e8fb3b2012-10-19 12:44:48 +00002// expected-no-diagnostics
Ted Kremenek6b4f5672011-04-27 05:34:09 +00003
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.
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