// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
#pragma omp parallel for simd
for(inti=0;i;i++)
c[i]=a[i];
// expected-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
#pragma omp parallel for simd
for(inti=0;jj<kk;ii++)
c[i]=a[i];
// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
#pragma omp parallel for simd
for(inti=0;!!i;i++)
c[i]=a[i];
// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
#pragma omp parallel for simd
for(inti=0;i!=1;i++)
c[i]=a[i];
// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
#pragma omp parallel for simd
for(inti=0;;i++)
c[i]=a[i];
// Ok.
#pragma omp parallel for simd
for(inti=11;i>10;i--)
c[i]=a[i];
// Ok.
#pragma omp parallel for simd
for(inti=0;i<10;++i)
c[i]=a[i];
// Ok.
#pragma omp parallel for simd
for(ii=0;ii<10;++ii)
c[ii]=a[ii];
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp parallel for simd
for(ii=0;ii<10;++jj)
c[ii]=a[jj];
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp parallel for simd
for(ii=0;ii<10;++++ii)
c[ii]=a[ii];
// Ok but undefined behavior (in general, cannot check that incr
// is really loop-invariant).
#pragma omp parallel for simd
for(ii=0;ii<10;ii=ii+ii)
c[ii]=a[ii];
// expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}
#pragma omp parallel for simd
for(ii=0;ii<10;ii=ii+1.0f)
c[ii]=a[ii];
// Ok - step was converted to integer type.
#pragma omp parallel for simd
for(ii=0;ii<10;ii=ii+(int)1.1f)
c[ii]=a[ii];
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp parallel for simd
for(ii=0;ii<10;jj=ii+2)
c[ii]=a[ii];
// expected-warning@+3 {{relational comparison result unused}}
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp parallel for simd
for(ii=0;ii<10;jj>kk+2)
c[ii]=a[ii];
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp parallel for simd
for(ii=0;ii<10;)
c[ii]=a[ii];
// expected-warning@+3 {{expression result unused}}
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp parallel for simd
for(ii=0;ii<10;!ii)
c[ii]=a[ii];
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp parallel for simd
for(ii=0;ii<10;ii?++ii:++jj)
c[ii]=a[ii];
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp parallel for simd
for(ii=0;ii<10;ii=ii<10)
c[ii]=a[ii];
// expected-note@+3 {{loop step is expected to be positive due to this condition}}
// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
#pragma omp parallel for simd
for(ii=0;ii<10;ii=ii+0)
c[ii]=a[ii];
// expected-note@+3 {{loop step is expected to be positive due to this condition}}
// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
#pragma omp parallel for simd
for(ii=0;ii<10;ii=ii+(int)(0.8-0.45))
c[ii]=a[ii];
// expected-note@+3 {{loop step is expected to be positive due to this condition}}
// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
#pragma omp parallel for simd
for(ii=0;(ii)<10;ii-=25)
c[ii]=a[ii];
// expected-note@+3 {{loop step is expected to be positive due to this condition}}
// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
#pragma omp parallel for simd
for(ii=0;(ii<10);ii-=0)
c[ii]=a[ii];
// expected-note@+3 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
#pragma omp parallel for simd
for(ii=0;ii>10;(ii+=0))
c[ii]=a[ii];
// expected-note@+3 {{loop step is expected to be positive due to this condition}}
// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
#pragma omp parallel for simd
for(ii=0;ii<10;(ii)=(1-1)+(ii))
c[ii]=a[ii];
// expected-note@+3 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
#pragma omp parallel for simd
for((ii=0);ii>10;(ii-=0))
c[ii]=a[ii];
// expected-note@+3 {{loop step is expected to be positive due to this condition}}
// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
#pragma omp parallel for simd
for(ii=0;(ii<10);(ii-=0))
c[ii]=a[ii];
// expected-note@+2 {{defined as firstprivate}}
// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
#pragma omp parallel for simd firstprivate(ii)
for(ii=0;ii<10;ii++)
c[ii]=a[ii];
#pragma omp parallel for simd linear(ii)
for(ii=0;ii<10;ii++)
c[ii]=a[ii];
// expected-note@+2 {{defined as private}}
// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be private, predetermined as linear}}
#pragma omp parallel for simd private(ii)
for(ii=0;ii<10;ii++)
c[ii]=a[ii];
// expected-note@+2 {{defined as lastprivate}}
// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be lastprivate, predetermined as linear}}
// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be threadprivate or thread local, predetermined as linear}}
break;// expected-error {{'break' statement cannot be used in OpenMP for loop}}
if(c[i]>11)
break;// expected-error {{'break' statement cannot be used in OpenMP for loop}}
}
#pragma omp parallel for simd
for(inti=0;i<10;i++){
for(intj=0;j<10;j++){
c[i]=a[i]+b[i];
if(c[i]>10){
if(c[i]<20){
break;// OK
}
}
}
}
}
voidtest_loop_eh(){
constintN=100;
floata[N],b[N],c[N];
#pragma omp parallel for simd
for(inti=0;i<10;i++){
c[i]=a[i]+b[i];
try{// expected-error {{'try' statement cannot be used in OpenMP simd region}}
for(intj=0;j<10;++j){
if(a[i]>b[j])
throwa[i];// expected-error {{'throw' statement cannot be used in OpenMP simd region}}
}
throwa[i];// expected-error {{'throw' statement cannot be used in OpenMP simd region}}
}catch(floatf){
if(f>0.1)
throwa[i];// expected-error {{'throw' statement cannot be used in OpenMP simd region}}
return;// expected-error {{cannot return from OpenMP region}}
}
switch(i){
case1:
b[i]++;
break;
default:
break;
}
for(intj=0;j<10;j++){
if(c[i]>10)
throwc[i];// expected-error {{'throw' statement cannot be used in OpenMP simd region}}
}
}
if(c[9]>10)
throwc[9];// OK
#pragma omp parallel for simd
for(inti=0;i<10;++i){
structS{
voidg(){throw0;}
};
}
}
voidtest_loop_firstprivate_lastprivate(){
Ss(4);
#pragma omp parallel for simd lastprivate(s) firstprivate(s)
for(inti=0;i<16;++i)
;
}
voidtest_ordered(){
#pragma omp parallel for simd ordered ordered // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'ordered' clause}}
// expected-error@+1 2 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel for simd'}}
#pragma omp parallel for simd nowait nowait // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'nowait' clause}}