268 lines · cpp
1// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -verify=expected,omp45 -std=c++11 %s -Wuninitialized2// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -verify=expected,omp5,omp50 -std=c++11 %s -Wuninitialized3// RUN: %clang_cc1 -fopenmp -verify=expected,omp5,omp51 -std=c++11 %s -Wuninitialized4 5// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -verify=expected,omp45 -std=c++11 %s -Wuninitialized6// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -verify=expected,omp5,omp50 -std=c++11 %s -Wuninitialized7// RUN: %clang_cc1 -fopenmp-simd -verify=expected,omp5,omp51 -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 simd13 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 simd // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute simd'}}24 25int main(int argc, char **argv) {26 #pragma omp target27 #pragma omp teams distribute simd28 f; // expected-error {{use of undeclared identifier 'f'}}29#pragma omp target30#pragma omp teams distribute simd { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}31 for (int i = 0; i < argc; ++i)32 foo();33#pragma omp target34#pragma omp teams distribute simd ( // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}35 for (int i = 0; i < argc; ++i)36 foo();37#pragma omp target38#pragma omp teams distribute simd[ // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}39 for (int i = 0; i < argc; ++i)40 foo();41#pragma omp target42#pragma omp teams distribute simd] // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}43 for (int i = 0; i < argc; ++i)44 foo();45#pragma omp target46#pragma omp teams distribute simd) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}47 for (int i = 0; i < argc; ++i)48 foo();49#pragma omp target50#pragma omp teams distribute simd } // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}51 for (int i = 0; i < argc; ++i)52 foo();53#pragma omp target54#pragma omp teams distribute simd55 for (int i = 0; i < argc; ++i)56 foo();57// expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}58#pragma omp target59#pragma omp teams distribute simd 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 simd67 for (int i = 0; i < argc; ++i)68 foo();69#pragma omp target70#pragma omp teams distribute simd71 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 simd81 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 simd 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 simd98 for (int i = 0; i < argc; ++i)99 L2:100 foo();101#pragma omp target102#pragma omp teams distribute simd103 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 simd110 for (int n = 0; n < 100; ++n) {111 }112 113#pragma omp target114#pragma omp teams distribute simd copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp teams distribute simd'}}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 simd ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute simd'}}123 for (int i = 0; i < 16; ++i)124 ;125}126 127void test_nontemporal() {128 int i;129#pragma omp target130// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}131#pragma omp teams distribute simd nontemporal(132 for (i = 0; i < 16; ++i)133 ;134#pragma omp target135// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 2 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}136#pragma omp teams distribute simd nontemporal(,137 for (i = 0; i < 16; ++i)138 ;139#pragma omp target140// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 2 {{expected expression}}141#pragma omp teams distribute simd nontemporal(, )142 for (i = 0; i < 16; ++i)143 ;144#pragma omp target145// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{expected expression}}146#pragma omp teams distribute simd nontemporal()147 for (i = 0; i < 16; ++i)148 ;149#pragma omp target150// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{expected '(' for function-style cast or type construction}}151#pragma omp teams distribute simd nontemporal(int)152 for (i = 0; i < 16; ++i)153 ;154#pragma omp target155// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} omp5-error@+1 {{expected variable name}}156#pragma omp teams distribute simd nontemporal(0)157 for (i = 0; i < 16; ++i)158 ;159#pragma omp target160// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{use of undeclared identifier 'x'}}161#pragma omp teams distribute simd nontemporal(x)162 for (i = 0; i < 16; ++i)163 ;164#pragma omp target165// expected-error@+2 {{use of undeclared identifier 'x'}}166// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{use of undeclared identifier 'y'}}167#pragma omp teams distribute simd nontemporal(x, y)168 for (i = 0; i < 16; ++i)169 ;170#pragma omp target171// expected-error@+3 {{use of undeclared identifier 'x'}}172// expected-error@+2 {{use of undeclared identifier 'y'}}173// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{use of undeclared identifier 'z'}}174#pragma omp teams distribute simd nontemporal(x, y, z)175 for (i = 0; i < 16; ++i)176 ;177 178 int x, y;179#pragma omp target180// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}181#pragma omp teams distribute simd nontemporal(x :)182 for (i = 0; i < 16; ++i)183 ;184#pragma omp target185// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}}186#pragma omp teams distribute simd nontemporal(x :, )187 for (i = 0; i < 16; ++i)188 ;189 190#pragma omp target191// omp5-note@+2 {{defined as nontemporal}}192// omp45-error@+1 2 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} omp5-error@+1 {{a variable cannot appear in more than one nontemporal clause}}193#pragma omp teams distribute simd nontemporal(x) nontemporal(x)194 for (i = 0; i < 16; ++i)195 ;196 197#pragma omp target198// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}}199#pragma omp teams distribute simd private(x) nontemporal(x)200 for (i = 0; i < 16; ++i)201 ;202 203#pragma omp target204// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}}205#pragma omp teams distribute simd nontemporal(x) private(x)206 for (i = 0; i < 16; ++i)207 ;208 209#pragma omp target210// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}}211#pragma omp teams distribute simd nontemporal(x, y : 0)212 for (i = 0; i < 16; ++i)213 ;214 215#pragma omp target216// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}}217#pragma omp teams distribute simd nontemporal(x) lastprivate(x)218 for (i = 0; i < 16; ++i)219 ;220 221#pragma omp target222// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}}223#pragma omp teams distribute simd lastprivate(x) nontemporal(x)224 for (i = 0; i < 16; ++i)225 ;226#pragma omp target227#pragma omp teams distribute simd order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} expected-error {{expected '(' after 'order'}}228 for (int i = 0; i < 10; ++i)229 ;230#pragma omp target231#pragma omp teams distribute simd order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}232 for (int i = 0; i < 10; ++i)233 ;234#pragma omp target235#pragma omp teams distribute simd order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}236 for (int i = 0; i < 10; ++i)237 ;238#pragma omp target239#pragma omp teams distribute simd order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}}240 for (int i = 0; i < 10; ++i)241 ;242#pragma omp target243#pragma omp teams distribute simd order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}}244 for (int i = 0; i < 10; ++i)245 ;246#pragma omp target247#pragma omp teams distribute simd order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}248 for (int i = 0; i < 10; ++i)249 ;250#pragma omp target251#pragma omp teams distribute simd order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}252 for (int i = 0; i < 10; ++i)253 ;254#pragma omp target255#pragma omp teams distribute simd order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}256 for (int i = 0; i < 10; ++i)257 ;258#pragma omp target259#pragma omp teams distribute simd order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}260 for (int i = 0; i < 10; ++i)261 ;262#pragma omp target263#pragma omp teams distribute simd order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} omp51-error {{directive '#pragma omp teams distribute simd' cannot contain more than one 'order' clause}}264 for (int i = 0; i < 10; ++i)265 ;266}267 268