aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/Darwin/gcd-async-norace.mm
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsan/Darwin/gcd-async-norace.mm')
-rw-r--r--test/tsan/Darwin/gcd-async-norace.mm26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/tsan/Darwin/gcd-async-norace.mm b/test/tsan/Darwin/gcd-async-norace.mm
new file mode 100644
index 000000000000..b987e00656fb
--- /dev/null
+++ b/test/tsan/Darwin/gcd-async-norace.mm
@@ -0,0 +1,26 @@
+// RUN: %clang_tsan %s -o %t -framework Foundation
+// RUN: %run %t 2>&1
+
+#import <Foundation/Foundation.h>
+
+long global;
+
+int main() {
+ NSLog(@"Hello world.");
+
+ global = 42;
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ global = 43;
+
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ CFRunLoopStop(CFRunLoopGetCurrent());
+ });
+ });
+
+ CFRunLoopRun();
+ NSLog(@"Done.");
+}
+
+// CHECK: Hello world.
+// CHECK: Done.
+// CHECK-NOT: WARNING: ThreadSanitizer