[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / tsan / ignore_free.cc
blob60369cc1baa57d348a148ad3427bbf5e25de2ee7
1 // RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <unistd.h>
7 extern "C" {
8 void AnnotateIgnoreReadsBegin(const char *f, int l);
9 void AnnotateIgnoreReadsEnd(const char *f, int l);
10 void AnnotateIgnoreWritesBegin(const char *f, int l);
11 void AnnotateIgnoreWritesEnd(const char *f, int l);
14 void *Thread(void *p) {
15 *(int*)p = 42;
16 return 0;
19 int main() {
20 int *p = new int(0);
21 pthread_t t;
22 pthread_create(&t, 0, Thread, p);
23 sleep(1);
24 AnnotateIgnoreReadsBegin(__FILE__, __LINE__);
25 AnnotateIgnoreWritesBegin(__FILE__, __LINE__);
26 free(p);
27 AnnotateIgnoreReadsEnd(__FILE__, __LINE__);
28 AnnotateIgnoreWritesEnd(__FILE__, __LINE__);
29 pthread_join(t, 0);
30 fprintf(stderr, "OK\n");
31 return 0;
34 // CHECK-NOT: WARNING: ThreadSanitizer: data race
35 // CHECK: OK