1 // RUN: %clangxx_tsan %s -o %t -framework Foundation -fobjc-arc
2 // RUN: %run %t 6 2>&1 | FileCheck %s --check-prefix=SIX
3 // RUN: not %run %t 7 2>&1 | FileCheck %s --check-prefix=SEVEN
5 #import <Foundation/Foundation.h>
7 static bool isTaggedPtr(id obj) {
8 uintptr_t ptr = (uintptr_t) obj;
9 return (ptr & 0x8000000000000001ull) != 0;
12 int main(int argc, char* argv[]) {
14 int arg = atoi(argv[1]);
17 NSObject* obj = [NSObject new];
18 NSObject* num1 = [NSNumber numberWithInt:7];
19 NSObject* num2 = [NSNumber numberWithInt:arg];
21 assert(!isTaggedPtr(obj));
22 assert(isTaggedPtr(num1) && isTaggedPtr(num2));
24 // obj -> num1 (includes num2)
33 // SEVEN: ThreadSanitizer: lock-order-inversion (potential deadlock)
39 // SIX-NOT: ThreadSanitizer