176 lines · cpp
1// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -std=c++11 %s -Wuninitialized2// RUN: %clang_cc1 -verify=expected,omp5,omp50 -fopenmp -fopenmp-version=50 -std=c++11 %s -Wuninitialized3// RUN: %clang_cc1 -verify=expected,omp5,omp51 -fopenmp -fopenmp-version=51 -std=c++11 %s -Wuninitialized4 5// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -std=c++11 %s -Wuninitialized6// RUN: %clang_cc1 -verify=expected,omp5,omp50 -fopenmp-simd -fopenmp-version=50 -std=c++11 %s -Wuninitialized7// RUN: %clang_cc1 -verify=expected,omp5,omp51 -fopenmp-simd -fopenmp-version=51 -std=c++11 %s -Wuninitialized8 9void xxx(int argc) {10 int x; // expected-note {{initialize the variable 'x' to silence this warning}}11#pragma omp target12#pragma omp teams distribute parallel for13 for (int i = 0; i < 10; ++i)14 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}15}16 17void foo() {18}19 20static int pvt;21#pragma omp threadprivate(pvt)22 23#pragma omp teams distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute parallel for'}}24 25int main(int argc, char **argv) {26 #pragma omp target27 #pragma omp teams distribute parallel for28 f; // expected-error {{use of undeclared identifier 'f'}}29#pragma omp target30#pragma omp teams distribute parallel for { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}31 for (int i = 0; i < argc; ++i)32 foo();33#pragma omp target34#pragma omp teams distribute parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}35 for (int i = 0; i < argc; ++i)36 foo();37#pragma omp target38#pragma omp teams distribute parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}39 for (int i = 0; i < argc; ++i)40 foo();41#pragma omp target42#pragma omp teams distribute parallel for] // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}43 for (int i = 0; i < argc; ++i)44 foo();45#pragma omp target46#pragma omp teams distribute parallel for) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}47 for (int i = 0; i < argc; ++i)48 foo();49#pragma omp target50#pragma omp teams distribute parallel for } // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}51 for (int i = 0; i < argc; ++i)52 foo();53#pragma omp target54#pragma omp teams distribute parallel for linear(argc) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp teams distribute parallel for'}}55 for (int i = 0; i < argc; ++i)56 foo();57// expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}58#pragma omp target59#pragma omp teams distribute parallel for unknown()60 for (int i = 0; i < argc; ++i)61 foo();62L1:63 for (int i = 0; i < argc; ++i)64 foo();65#pragma omp target66#pragma omp teams distribute parallel for67 for (int i = 0; i < argc; ++i)68 foo();69#pragma omp target70#pragma omp teams distribute parallel for71 for (int i = 0; i < argc; ++i) {72 goto L1; // expected-error {{use of undeclared label 'L1'}}73 argc++;74 }75 76 for (int i = 0; i < 10; ++i) {77 switch (argc) {78 case (0):79#pragma omp target80#pragma omp teams distribute parallel for81 for (int i = 0; i < argc; ++i) {82 foo();83 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}84 continue;85 }86 default:87 break;88 }89 }90#pragma omp target91#pragma omp teams distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}92 for (int i = 0; i < 10; ++i)93 ++argc; // expected-error {{ariable 'argc' must have explicitly specified data sharing attributes}}94 95 goto L2; // expected-error {{use of undeclared label 'L2'}}96#pragma omp target97#pragma omp teams distribute parallel for98 for (int i = 0; i < argc; ++i)99 L2:100 foo();101#pragma omp target102#pragma omp teams distribute parallel for103 for (int i = 0; i < argc; ++i) {104 return 1; // expected-error {{cannot return from OpenMP region}}105 }106 107 [[]] // expected-error {{an attribute list cannot appear here}}108#pragma omp target109#pragma omp teams distribute parallel for110 for (int n = 0; n < 100; ++n) {111 }112 113#pragma omp target114#pragma omp teams distribute parallel for copyin(pvt)115 for (int n = 0; n < 100; ++n) {}116 117 return 0;118}119 120void test_ordered() {121#pragma omp target122#pragma omp teams distribute parallel for ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute parallel for'}}123 for (int i = 0; i < 16; ++i)124 ;125#pragma omp target126#pragma omp teams distribute parallel for order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected '(' after 'order'}}127 for (int i = 0; i < 10; ++i)128 ;129#pragma omp target130#pragma omp teams distribute parallel for order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}131 for (int i = 0; i < 10; ++i)132 ;133#pragma omp target134#pragma omp teams distribute parallel for order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}135 for (int i = 0; i < 10; ++i)136 ;137#pragma omp target138#pragma omp teams distribute parallel for order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}}139 for (int i = 0; i < 10; ++i)140 ;141#pragma omp target142#pragma omp teams distribute parallel for order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}}143 for (int i = 0; i < 10; ++i)144 ;145#pragma omp target146#pragma omp teams distribute parallel for order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}147 for (int i = 0; i < 10; ++i)148 ;149#pragma omp target150#pragma omp teams distribute parallel for order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}151 for (int i = 0; i < 10; ++i)152 ;153#pragma omp target154#pragma omp teams distribute parallel for order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}155 for (int i = 0; i < 10; ++i)156 ;157#pragma omp target158#pragma omp teams distribute parallel for order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}159 for (int i = 0; i < 10; ++i)160 ;161#pragma omp target162#pragma omp teams distribute parallel for order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} omp51-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'order' clause}}163 for (int i = 0; i < 10; ++i)164 ;165}166 167void test_cancel() {168#pragma omp target169#pragma omp teams distribute parallel for170 for (int i = 0; i < 16; ++i) {171#pragma omp cancel for172 ;173 }174}175 176