Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / static_init7.cpp
blob7d48302170fd7a362ce870fd4a88a1b0ce6baf4a
1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <stdlib.h>
6 struct P {
7 int x;
8 int y;
9 };
11 int Helper() {
12 try {
13 static int i = []() {
14 throw P{};
15 return 1;
16 }();
17 return i;
18 } catch (P) {
19 return 0;
23 void *Thread(void *x) {
24 for (int i = 0; i < 1000; ++i) {
25 Helper();
27 return 0;
30 int main() {
31 pthread_t t[2];
32 pthread_create(&t[0], 0, Thread, 0);
33 pthread_create(&t[1], 0, Thread, 0);
34 pthread_join(t[0], 0);
35 pthread_join(t[1], 0);
36 fprintf(stderr, "PASS\n");
39 // CHECK-NOT: WARNING: ThreadSanitizer: data race