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 // expected-no-diagnostics 5 6 #ifndef HEADER 7 #define HEADER 8 9 void foo() {} 10 11 template <class T, int N> 12 T tmain(T argc) { 13 T b = argc, c, d, e, f, h; 14 static T a; 15 // CHECK: static T a; 16 static T g; 17 #pragma omp threadprivate(g) 18 #pragma omp parallel for schedule(dynamic) default(none) copyin(g) linear(a) 19 // CHECK: #pragma omp parallel for schedule(dynamic) default(none) copyin(g) linear(a) 20 for (int i = 0; i < 2; ++i) 21 a = 2; 22 // CHECK-NEXT: for (int i = 0; i < 2; ++i) 23 // CHECK-NEXT: a = 2; 24 #pragma omp parallel for private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered(N) if (parallel :argc) num_threads(N) default(shared) shared(e) reduction(+ : h) linear(a:N) 25 for (int i = 0; i < 2; ++i) 26 for (int j = 0; j < 2; ++j) 27 for (int j = 0; j < 2; ++j) 28 for (int j = 0; j < 2; ++j) 29 for (int j = 0; j < 2; ++j) 30 for (int i = 0; i < 2; ++i) 31 for (int j = 0; j < 2; ++j) 32 for (int j = 0; j < 2; ++j) 33 for (int j = 0; j < 2; ++j) 34 for (int j = 0; j < 2; ++j) 35 foo(); 36 // CHECK-NEXT: #pragma omp parallel for private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h) linear(a: N) 37 // CHECK-NEXT: for (int i = 0; i < 2; ++i) 38 // CHECK-NEXT: for (int j = 0; j < 2; ++j) 39 // CHECK-NEXT: for (int j = 0; j < 2; ++j) 40 // CHECK-NEXT: for (int j = 0; j < 2; ++j) 41 // CHECK-NEXT: for (int j = 0; j < 2; ++j) 42 // CHECK-NEXT: for (int i = 0; i < 2; ++i) 43 // CHECK-NEXT: for (int j = 0; j < 2; ++j) 44 // CHECK-NEXT: for (int j = 0; j < 2; ++j) 45 // CHECK-NEXT: for (int j = 0; j < 2; ++j) 46 // CHECK-NEXT: for (int j = 0; j < 2; ++j) 47 // CHECK-NEXT: foo(); 48 return T(); 49 } 50 51 int main(int argc, char **argv) { 52 int b = argc, c, d, e, f, h; 53 static int a; 54 // CHECK: static int a; 55 static float g; 56 #pragma omp threadprivate(g) 57 #pragma omp parallel for schedule(guided, argc) default(none) copyin(g) linear(a) 58 // CHECK: #pragma omp parallel for schedule(guided, argc) default(none) copyin(g) linear(a) 59 for (int i = 0; i < 2; ++i) 60 a = 2; 61 // CHECK-NEXT: for (int i = 0; i < 2; ++i) 62 // CHECK-NEXT: a = 2; 63 #pragma omp parallel for private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) schedule(auto) ordered if (argc) num_threads(a) default(shared) shared(e) reduction(+ : h) linear(a:-5) 64 for (int i = 0; i < 10; ++i) 65 for (int j = 0; j < 10; ++j) 66 foo(); 67 // CHECK-NEXT: #pragma omp parallel for private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) schedule(auto) ordered if(argc) num_threads(a) default(shared) shared(e) reduction(+: h) linear(a: -5) 68 // CHECK-NEXT: for (int i = 0; i < 10; ++i) 69 // CHECK-NEXT: for (int j = 0; j < 10; ++j) 70 // CHECK-NEXT: foo(); 71 return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0])); 72 } 73 74 #endif 75