173 lines · cpp
1// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -ferror-limit 100 -std=c++11 -o - %s -fopenmp-version=45 -Wuninitialized2// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized3// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized4 5// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -fopenmp-version=45 -Wuninitialized6// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized7// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized8 9void foo() {10}11 12void xxx(int argc) {13 int x; // expected-note {{initialize the variable 'x' to silence this warning}}14#pragma omp distribute parallel for15 for (int i = 0; i < 10; ++i)16 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}17}18 19#pragma omp distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp distribute parallel for'}}20 21int main(int argc, char **argv) {22#pragma omp distribute parallel for order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} expected-error {{expected '(' after 'order'}}23 for (int i = 0; i < argc; ++i)24 foo();25#pragma omp distribute parallel for order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}26 for (int i = 0; i < argc; ++i)27 foo();28#pragma omp distribute parallel for order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}29 for (int i = 0; i < argc; ++i)30 foo();31#pragma omp distribute parallel for order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}}32 for (int i = 0; i < argc; ++i)33 foo();34#pragma omp distribute parallel for order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}}35 for (int i = 0; i < argc; ++i)36 foo();37#pragma omp distribute parallel for order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}38 for (int i = 0; i < argc; ++i)39 foo();40#pragma omp distribute parallel for order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}41 for (int i = 0; i < argc; ++i)42 foo();43#pragma omp distribute parallel for order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}44 for (int i = 0; i < argc; ++i)45 foo();46#pragma omp distribute parallel for order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}47 for (int i = 0; i < argc; ++i)48 foo();49#pragma omp distribute parallel for order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} omp51-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'order' clause}}50 for (int i = 0; i < argc; ++i)51 foo();52#pragma omp target53#pragma omp teams54#pragma omp distribute parallel for { // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}55 for (int i = 0; i < argc; ++i)56 foo();57#pragma omp target58#pragma omp teams59#pragma omp distribute parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}60 for (int i = 0; i < argc; ++i)61 foo();62#pragma omp target63#pragma omp teams64#pragma omp distribute parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}65 for (int i = 0; i < argc; ++i)66 foo();67#pragma omp target68#pragma omp teams69#pragma omp distribute parallel for] // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}70 for (int i = 0; i < argc; ++i)71 foo();72#pragma omp target73#pragma omp teams74#pragma omp distribute parallel for) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}75 for (int i = 0; i < argc; ++i)76 foo();77#pragma omp target78#pragma omp teams79#pragma omp distribute parallel for } // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}80 for (int i = 0; i < argc; ++i)81 foo();82#pragma omp target83#pragma omp teams84#pragma omp distribute parallel for linear(argc) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp distribute parallel for'}}85 for (int i = 0; i < argc; ++i)86 foo();87#pragma omp target88#pragma omp teams89#pragma omp distribute parallel for unknown() // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}90 for (int i = 0; i < argc; ++i)91 foo();92L1:93 for (int i = 0; i < argc; ++i)94 foo();95#pragma omp target96#pragma omp teams97#pragma omp distribute parallel for98 for (int i = 0; i < argc; ++i)99 foo();100#pragma omp target101#pragma omp teams102#pragma omp distribute parallel for103 for (int i = 0; i < argc; ++i) {104 goto L1; // expected-error {{use of undeclared label 'L1'}}105 argc++;106 }107 108 for (int i = 0; i < 10; ++i) {109 switch (argc) {110 case (0):111#pragma omp target112#pragma omp teams113#pragma omp distribute parallel for114 for (int i = 0; i < argc; ++i) {115 foo();116 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}117 continue;118 }119 default:120 break;121 }122 }123#pragma omp target124#pragma omp teams125#pragma omp distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}126 for (int i = 0; i < 10; ++i)127 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}128 129 goto L2; // expected-error {{use of undeclared label 'L2'}}130#pragma omp target131#pragma omp teams132#pragma omp distribute parallel for133 for (int i = 0; i < argc; ++i)134 L2:135 foo();136#pragma omp target137#pragma omp teams138#pragma omp distribute parallel for139 for (int i = 0; i < argc; ++i) {140 return 1; // expected-error {{cannot return from OpenMP region}}141 }142 143 [[]] // expected-error {{an attribute list cannot appear here}}144#pragma omp target145#pragma omp teams146#pragma omp distribute parallel for147 for (int n = 0; n < 100; ++n) {148 }149 150 return 0;151}152 153void test_ordered() {154#pragma omp target155#pragma omp teams156#pragma omp distribute parallel for collapse(2) collapse(3) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'collapse' clause}}157 for (int i = 0; i < 16; ++i)158 for (int j = 0; j < 16; ++j)159 ;160}161 162void test_cancel() {163#pragma omp target164#pragma omp teams165#pragma omp distribute parallel for166 for (int i = 0; i < 16; ++i)167 for (int j = 0; j < 16; ++j) {168#pragma omp cancel for169 ;170 }171}172 173