// expected-note@+1 {{defined as threadprivate or thread local}}
#pragma omp threadprivate(sii)
staticintglobalii;
inttest_iteration_spaces(){
constintN=100;
floata[N],b[N],c[N];
intii,jj,kk;
floatfii;
doubledii;
#pragma omp target teams distribute
for(inti=0;i<10;i+=1){
c[i]=a[i]+b[i];
}
#pragma omp target teams distribute
for(chari=0;i<10;i++){
c[i]=a[i]+b[i];
}
#pragma omp target teams distribute
for(chari=0;i<10;i+='\1'){
c[i]=a[i]+b[i];
}
#pragma omp target teams distribute
for(longlongi=0;i<10;i++){
c[i]=a[i]+b[i];
}
#pragma omp target teams distribute
// expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'double'}}
for(longlongi=0;i<10;i+=1.5){
c[i]=a[i]+b[i];
}
#pragma omp target teams distribute
for(longlongi=0;i<'z';i+=1u){
c[i]=a[i]+b[i];
}
#pragma omp target teams distribute
// expected-error@+1 {{variable must be of integer or random access iterator type}}
for(floatfi=0;fi<10.0;fi++){
c[(int)fi]=a[(int)fi]+b[(int)fi];
}
#pragma omp target teams distribute
// expected-error@+1 {{variable must be of integer or random access iterator type}}
for(doublefi=0;fi<10.0;fi++){
c[(int)fi]=a[(int)fi]+b[(int)fi];
}
#pragma omp target teams distribute
// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
for(int&ref=ii;ref<10;ref++){
}
#pragma omp target teams distribute
// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
for(inti;i<10;i++)
c[i]=a[i];
#pragma omp target teams distribute
// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
for(inti=0,j=0;i<10;++i)
c[i]=a[i];
#pragma omp target teams distribute
// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
for(;ii<10;++ii)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-warning@+2 {{expression result unused}}
// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
for(ii+1;ii<10;++ii)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
for(c[ii]=0;ii<10;++ii)
c[ii]=a[ii];
#pragma omp target teams distribute
// Ok to skip parenthesises.
for(((ii))=0;ii<10;++ii)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
for(inti=0;i;i++)
c[i]=a[i];
#pragma omp target teams distribute
// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
for(inti=0;jj<kk;ii++)
c[i]=a[i];
#pragma omp target teams distribute
// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
for(inti=0;!!i;i++)
c[i]=a[i];
#pragma omp target teams distribute
// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
for(inti=0;i!=1;i++)
c[i]=a[i];
#pragma omp target teams distribute
// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
for(inti=0;;i++)
c[i]=a[i];
// Ok.
#pragma omp target teams distribute
for(inti=11;i>10;i--)
c[i]=a[i];
// Ok.
#pragma omp target teams distribute
for(inti=0;i<10;++i)
c[i]=a[i];
// Ok.
#pragma omp target teams distribute
for(ii=0;ii<10;++ii)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
for(ii=0;ii<10;++jj)
c[ii]=a[jj];
#pragma omp target teams distribute
// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
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 target teams distribute
for(ii=0;ii<10;ii=ii+ii)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'float'}}
for(ii=0;ii<10;ii=ii+1.0f)
c[ii]=a[ii];
// Ok - step was converted to integer type.
#pragma omp target teams distribute
for(ii=0;ii<10;ii=ii+(int)1.1f)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
for(ii=0;ii<10;jj=ii+2)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-warning@+2 {{relational comparison result unused}}
// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
for(ii=0;ii<10;jj>kk+2)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
for(ii=0;ii<10;)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-warning@+2 {{expression result unused}}
// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
for(ii=0;ii<10;!ii)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
for(ii=0;ii<10;ii?++ii:++jj)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
for(ii=0;ii<10;ii=ii<10)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-note@+2 {{loop step is expected to be positive due to this condition}}
// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
for(ii=0;ii<10;ii=ii+0)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-note@+2 {{loop step is expected to be positive due to this condition}}
// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
for(ii=0;ii<10;ii=ii+(int)(0.8-0.45))
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-note@+2 {{loop step is expected to be positive due to this condition}}
// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
for(ii=0;(ii)<10;ii-=25)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-note@+2 {{loop step is expected to be positive due to this condition}}
// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
for(ii=0;(ii<10);ii-=0)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-note@+2 {{loop step is expected to be negative due to this condition}}
// expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
for(ii=0;ii>10;(ii+=0))
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-note@+2 {{loop step is expected to be positive due to this condition}}
// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
for(ii=0;ii<10;(ii)=(1-1)+(ii))
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-note@+2 {{loop step is expected to be negative due to this condition}}
// expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
for((ii=0);ii>10;(ii-=0))
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-note@+2 {{loop step is expected to be positive due to this condition}}
// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
for(ii=0;(ii<10);(ii-=0))
c[ii]=a[ii];
#pragma omp target teams distribute firstprivate(ii) // expected-note {{defined as firstprivate}}
// expected-error@+1 {{loop iteration variable in the associated loop of 'omp target teams distribute' directive may not be firstprivate, predetermined as private}}
for(ii=0;ii<10;ii++)
c[ii]=a[ii];
#pragma omp target teams distribute private(ii)
// OK
for(ii=0;ii<10;ii++)
c[ii]=a[ii];
#pragma omp target teams distribute lastprivate(ii)
// OK
for(ii=0;ii<10;ii++)
c[ii]=a[ii];
#pragma omp target teams distribute
// expected-error@+1 {{loop iteration variable in the associated loop of 'omp target teams distribute' directive may not be threadprivate or thread local, predetermined as private}}
for(sii=0;sii<10;sii++)
c[sii]=a[sii];
{
#pragma omp target teams distribute collapse(2)
for(ii=0;ii<10;ii+=1)
for(globalii=0;globalii<10;globalii+=1)
c[globalii]+=a[globalii]+ii;
}
#pragma omp target teams distribute
// expected-error@+1 {{statement after '#pragma omp target teams distribute' must be a for loop}}
for(auto&item:a){
item=item+1;
}
#pragma omp target teams distribute
// expected-note@+2 {{loop step is expected to be positive due to this condition}}
// expected-error@+1 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
for(unsignedi=9;i<10;i--){
c[i]=a[i]+b[i];
}
int(*lb)[4]=nullptr;
#pragma omp target teams distribute
for(int(*p)[4]=lb;p<lb+8;++p){
}
#pragma omp target teams distribute
// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}