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
4
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
9
10 #ifndef HEADER
11 #define HEADER
12
foo()13 void foo() {}
14
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>
tmain(T argc,char ** argv)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
48 {
49 int b = 10;
50 T c = 100;
51 a = b + c;
52 }
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;
59 }
60
main(int argc,char ** argv)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);
77 }
78
79 #endif
80