brintos

brintos / llvm-project-archived public Read only

0
0
Text · 650 B · ba4615f Raw
35 lines · plain
1// RUN: %clangxx_tsan %s -o %t -framework Foundation -std=c++112// RUN: %run %t 2>&1 | FileCheck %s3 4#import <Foundation/Foundation.h>5 6#import <iostream>7#import <thread>8 9long my_global;10std::once_flag once_token;11 12void thread_func() {13  std::call_once(once_token, [] {14    my_global = 17;15  });16 17  long val = my_global;18  fprintf(stderr, "my_global = %ld\n", val);19}20 21int main(int argc, const char *argv[]) {22  fprintf(stderr, "Hello world.\n");23 24  std::thread t1(thread_func);25  std::thread t2(thread_func);26  t1.join();27  t2.join();28 29  fprintf(stderr, "Done.\n");30}31 32// CHECK: Hello world.33// CHECK-NOT: WARNING: ThreadSanitizer34// CHECK: Done.35