112 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=50 -triple x86_64-unknown-unknown -verify=expected,omp50 %s -Wuninitialized2// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=51 -triple x86_64-unknown-unknown -verify=expected,omp51 %s -Wuninitialized3// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=52 -triple x86_64-unknown-unknown -verify=expected,omp51 %s -Wuninitialized4// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=60 -triple x86_64-unknown-unknown -verify=expected,omp60 %s -Wuninitialized5 6// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=50 -triple x86_64-unknown-unknown -verify=expected,omp50 %s -Wuninitialized7// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=51 -triple x86_64-unknown-unknown -verify=expected,omp51 %s -Wuninitialized8// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=52 -triple x86_64-unknown-unknown -verify=expected,omp51 %s -Wuninitialized9// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=60 -triple x86_64-unknown-unknown -verify=expected,omp60 %s -Wuninitialized10 11// Constructs strictly nestable in a construct with order(concurrent) specified vary by OpenMP version:12// OMP5.0,5.1,5.2: loop, parallel, simd, and combined constructs with parallel as the first component.13// OMP6.0: in addition to the ones allowed in OMP5.x, also atomic and all loop-transformation constructs.14 15extern int omp_get_num_threads (void);16 17int main(int argc, char **argv) {18 int A = 0;19#pragma omp parallel for order(concurrent)20 for (int i = 0; i < 10; ++i)21 omp_get_num_threads(); // omp50-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}} omp51-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}} omp60-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}}22 23#pragma omp parallel for order(reproducible:concurrent) // omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}24 for (int i = 0; i < 10; ++i)25 omp_get_num_threads(); // omp51-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}} omp60-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}}26 27#pragma omp parallel for order(unconstrained:concurrent) // omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}28 for (int i = 0; i < 10; ++i)29 omp_get_num_threads(); // omp51-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}} omp60-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}}30 31#pragma omp parallel for order(concurrent)32 for (int i = 0; i < 10; ++i) {33 for (int j = 0; j < 10; ++j) {34 omp_get_num_threads(); // omp50-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}} omp51-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}} omp60-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}}35 }36 }37 38// nested atomic: OK in OMP6.0 but not in OMP5.x39#pragma omp parallel for order(concurrent)40 for (int i = 0; i < 10; ++i) {41#pragma omp atomic //omp50-error {{construct 'atomic' not allowed in a region associated with a directive with 'order' clause}} omp51-error {{construct 'atomic' not allowed in a region associated with a directive with 'order' clause}}42 A++;43 }44 45// nested loop-transformation construct: OK in OMP6.0 but not in OMP5.x46#pragma omp parallel for order(concurrent)47 for (int i = 0; i < 10; ++i) {48#pragma omp unroll //omp50-error {{construct 'unroll' not allowed in a region associated with a directive with 'order' clause}} omp51-error {{construct 'unroll' not allowed in a region associated with a directive with 'order' clause}}49 for (int j = 0; j < 10; ++j);50 }51 52#pragma omp parallel for order(reproducible: concurrent) // omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}53 for (int i = 0; i < 10; ++i) {54#pragma omp target //omp51-error {{construct 'target' not allowed in a region associated with a directive with 'order' clause}} omp60-error {{construct 'target' not allowed in a region associated with a directive with 'order' clause}}55 A++;56 }57 58#pragma omp parallel for order(unconstrained: concurrent) // omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}59 for (int i = 0; i < 10; ++i) {60#pragma omp target //omp51-error {{construct 'target' not allowed in a region associated with a directive with 'order' clause}} omp60-error {{construct 'target' not allowed in a region associated with a directive with 'order' clause}}61 A++;62 }63 64#pragma omp loop bind(parallel) order(concurrent)65 for (int i = 0; i < 10; ++i) {66#pragma omp parallel for67 for (int j = 0; j < 10; ++j) {68 A += j;69 }70 }71 72#pragma omp distribute order(concurrent)73 for (int i = 0; i < 10; ++i) {74#pragma omp parallel for simd75 for (int j = 0; j < 10; ++j) {76 A += j;77 }78 }79 80#pragma omp for order(concurrent)81 for (int i = 0; i < 10; ++i) {82#pragma omp parallel master83 for (int j = 0; j < 10; ++j) {84 A += j;85 }86 }87 88#pragma omp for order(concurrent)89 for (int i = 0; i < 10; ++i) {90#pragma omp parallel master taskloop91 for (int j = 0; j < 10; ++j) {92 A += j;93 }94 }95 96#pragma omp for order(concurrent)97 for (int i = 0; i < 10; ++i) {98#pragma omp parallel master taskloop simd99 for (int j = 0; j < 10; ++j) {100 A += j;101 }102 }103 104#pragma omp for order(concurrent)105 for (int i = 0; i < 10; ++i) {106 #pragma omp parallel sections107 {108 A++;109 }110 }111}112