| 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 | |
| 13 | void foo() {} |
| 14 | |
| 15 | template <class T, int N> |
| 16 | T tmain(T argc) { |
| 17 | T b = argc, c, d, e, f, g; |
| 18 | static T a; |
| 19 | // CHECK: static T a; |
| 20 | #pragma omp parallel |
| 21 | #pragma omp sections private(argc, b), firstprivate(c, d), lastprivate(d, f) reduction(- : g) nowait allocate(d) |
| 22 | { |
| 23 | foo(); |
| 24 | } |
| 25 | // CHECK-NEXT: #pragma omp parallel |
| 26 | // CHECK-NEXT: #pragma omp sections private(argc,b) firstprivate(c,d) lastprivate(d,f) reduction(-: g) nowait allocate(d){{$}} |
| 27 | // CHECK-NEXT: { |
| 28 | // CHECK-NEXT: foo(); |
| 29 | // CHECK-NEXT: } |
| 30 | return T(); |
| 31 | } |
| 32 | |
| 33 | int main(int argc, char **argv) { |
| 34 | // CHECK: int main(int argc, char **argv) { |
| 35 | int b = argc, c, d, e, f, g; |
| 36 | static int a; |
| 37 | // CHECK: static int a; |
| 38 | #pragma omp parallel |
| 39 | #pragma omp sections allocate(c) private(argc, b), firstprivate(argv, c), lastprivate(d, f) reduction(+ : g) nowait |
| 40 | { |
| 41 | #pragma omp section |
| 42 | foo(); |
| 43 | #pragma omp section |
| 44 | foo(); |
| 45 | } |
| 46 | // CHECK-NEXT: #pragma omp parallel |
| 47 | // CHECK-NEXT: #pragma omp sections allocate(c) private(argc,b) firstprivate(argv,c) lastprivate(d,f) reduction(+: g) nowait |
| 48 | // CHECK-NEXT: { |
| 49 | // CHECK-NEXT: #pragma omp section{{$}} |
| 50 | // CHECK-NEXT: foo(); |
| 51 | // CHECK-NEXT: #pragma omp section |
| 52 | // CHECK-NEXT: foo(); |
| 53 | // CHECK-NEXT: } |
| 54 | return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0])); |
| 55 | } |
| 56 | |
| 57 | #endif |
| 58 | |