Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / critical_ast_print.cpp
blob20cb9bf99a6f14d9f717a3d547d97005c8684b58
1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
5 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
6 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
8 // expected-no-diagnostics
10 #ifndef HEADER
11 #define HEADER
13 void foo() {}
15 // CHECK: template <typename T, int N> int tmain(T argc, char **argv)
16 // CHECK: static int a;
17 // CHECK-NEXT: #pragma omp critical{{$}}
18 // CHECK-NEXT: a = argv[0][0];
19 // CHECK-NEXT: ++a;
20 // CHECK-NEXT: #pragma omp critical{{$}}
21 // CHECK-NEXT: {
22 // CHECK-NEXT: int b = 10;
23 // CHECK-NEXT: T c = 100;
24 // CHECK-NEXT: a = b + c;
25 // CHECK-NEXT: }
26 // CHECK-NEXT: #pragma omp critical (the_name) hint(N){{$}}
27 // CHECK-NEXT: foo();
28 // CHECK-NEXT: return N;
29 // CHECK: template<> int tmain<int, 4>(int argc, char **argv)
30 template <typename T, int N>
31 int tmain(T argc, char **argv) {
32 T b = argc, c, d, e, f, g;
33 static int a;
34 // CHECK: static int a;
35 #pragma omp critical
36 a = argv[0][0];
37 ++a;
38 // CHECK-NEXT: #pragma omp critical
39 // CHECK-NEXT: a = argv[0][0];
40 // CHECK-NEXT: ++a;
41 // CHECK-NEXT: #pragma omp critical{{$}}
42 // CHECK-NEXT: {
43 // CHECK-NEXT: int b = 10;
44 // CHECK-NEXT: int c = 100;
45 // CHECK-NEXT: a = b + c;
46 // CHECK-NEXT: }
47 #pragma omp critical
49 int b = 10;
50 T c = 100;
51 a = b + c;
53 #pragma omp critical(the_name) hint(N)
54 foo();
55 // CHECK-NEXT: #pragma omp critical (the_name) hint(4)
56 // CHECK-NEXT: foo();
57 // CHECK-NEXT: return 4;
58 return N;
61 int main (int argc, char **argv) {
62 int b = argc, c, d, e, f, g;
63 static int a;
64 // CHECK: static int a;
65 #pragma omp critical
66 a=2;
67 // CHECK-NEXT: #pragma omp critical
68 // CHECK-NEXT: a = 2;
69 // CHECK-NEXT: ++a;
70 ++a;
71 #pragma omp critical (the_name1) hint(23)
72 foo();
73 // CHECK-NEXT: #pragma omp critical (the_name1) hint(23)
74 // CHECK-NEXT: foo();
75 // CHECK-NEXT: return tmain<int, 4>(a, argv);
76 return tmain<int, 4>(a, argv);
79 #endif