// expected-note@+1 {{defined as threadprivate or thread local}}
#pragma omp threadprivate(sii)
staticintglobalii;
// Currently, we cannot use "0" for global register variables.
// register int reg0 __asm__("0");
intreg0;
inttest_iteration_spaces(){
constintN=100;
floata[N],b[N],c[N];
intii,jj,kk;
floatfii;
doubledii;
registerintreg;// expected-warning {{'register' storage class specifier is deprecated}}
#pragma omp parallel
#pragma omp master taskloop simd
for(inti=0;i<10;i+=1){
c[i]=a[i]+b[i];
}
#pragma omp parallel
#pragma omp master taskloop simd
for(chari=0;i<10;i++){
c[i]=a[i]+b[i];
}
#pragma omp parallel
#pragma omp master taskloop simd
for(chari=0;i<10;i+='\1'){
c[i]=a[i]+b[i];
}
#pragma omp parallel
#pragma omp master taskloop simd
for(longlongi=0;i<10;i++){
c[i]=a[i]+b[i];
}
#pragma omp parallel
// expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'double'}}
#pragma omp master taskloop simd
for(longlongi=0;i<10;i+=1.5){
c[i]=a[i]+b[i];
}
#pragma omp parallel
#pragma omp master taskloop simd
for(longlongi=0;i<'z';i+=1u){
c[i]=a[i]+b[i];
}
#pragma omp parallel
// expected-error@+2 {{variable must be of integer or random access iterator type}}
#pragma omp master taskloop simd
for(floatfi=0;fi<10.0;fi++){
c[(int)fi]=a[(int)fi]+b[(int)fi];
}
#pragma omp parallel
// expected-error@+2 {{variable must be of integer or random access iterator type}}
#pragma omp master taskloop simd
for(doublefi=0;fi<10.0;fi++){
c[(int)fi]=a[(int)fi]+b[(int)fi];
}
#pragma omp parallel
// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(int&ref=ii;ref<10;ref++){
}
#pragma omp parallel
// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(inti;i<10;i++)
c[i]=a[i];
#pragma omp parallel
// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(inti=0,j=0;i<10;++i)
c[i]=a[i];
#pragma omp parallel
// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(;ii<10;++ii)
c[ii]=a[ii];
#pragma omp parallel
// expected-warning@+3 {{expression result unused}}
// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(ii+1;ii<10;++ii)
c[ii]=a[ii];
#pragma omp parallel
// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(c[ii]=0;ii<10;++ii)
c[ii]=a[ii];
#pragma omp parallel
// Ok to skip parenthesises.
#pragma omp master taskloop simd
for(((ii))=0;ii<10;++ii)
c[ii]=a[ii];
#pragma omp parallel
// omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
#pragma omp master taskloop simd
for(inti=0;i;i++)
c[i]=a[i];
#pragma omp parallel
// omp4-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-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 master taskloop simd
for(inti=0;jj<kk;ii++)
c[i]=a[i];
#pragma omp parallel
// omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
#pragma omp master taskloop simd
for(inti=0;!!i;i++)
c[i]=a[i];
#pragma omp parallel
// omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
#pragma omp master taskloop simd
for(inti=0;i!=1;i++)
c[i]=a[i];
#pragma omp parallel
// omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
#pragma omp master taskloop simd
for(inti=0;;i++)
c[i]=a[i];
#pragma omp parallel
// Ok.
#pragma omp master taskloop simd
for(inti=11;i>10;i--)
c[i]=a[i];
#pragma omp parallel
// Ok.
#pragma omp master taskloop simd
for(inti=0;i<10;++i)
c[i]=a[i];
#pragma omp parallel
// Ok.
#pragma omp master taskloop simd
for(ii=0;ii<10;++ii)
c[ii]=a[ii];
#pragma omp parallel
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp master taskloop simd
for(ii=0;ii<10;++jj)
c[ii]=a[jj];
#pragma omp parallel
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp master taskloop simd
for(ii=0;ii<10;++++ii)
c[ii]=a[ii];
#pragma omp parallel
// Ok but undefined behavior (in general, cannot check that incr
// is really loop-invariant).
#pragma omp master taskloop simd
for(ii=0;ii<10;ii=ii+ii)
c[ii]=a[ii];
#pragma omp parallel
// expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}
#pragma omp master taskloop simd
for(ii=0;ii<10;ii=ii+1.0f)
c[ii]=a[ii];
#pragma omp parallel
// Ok - step was converted to integer type.
#pragma omp master taskloop simd
for(ii=0;ii<10;ii=ii+(int)1.1f)
c[ii]=a[ii];
#pragma omp parallel
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp master taskloop simd
for(ii=0;ii<10;jj=ii+2)
c[ii]=a[ii];
#pragma omp parallel
// 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 master taskloop simd
for(ii=0;ii<10;jj>kk+2)
c[ii]=a[ii];
#pragma omp parallel
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp master taskloop simd
for(ii=0;ii<10;)
c[ii]=a[ii];
#pragma omp parallel
// 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 master taskloop simd
for(ii=0;ii<10;!ii)
c[ii]=a[ii];
#pragma omp parallel
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp master taskloop simd
for(ii=0;ii<10;ii?++ii:++jj)
c[ii]=a[ii];
#pragma omp parallel
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
#pragma omp master taskloop simd
for(ii=0;ii<10;ii=ii<10)
c[ii]=a[ii];
#pragma omp parallel
// 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 master taskloop simd
for(ii=0;ii<10;ii=ii+0)
c[ii]=a[ii];
#pragma omp parallel
// 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 master taskloop simd
for(ii=0;ii<10;ii=ii+(int)(0.8-0.45))
c[ii]=a[ii];
#pragma omp parallel
// 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 master taskloop simd
for(ii=0;(ii)<10;ii-=25)
c[ii]=a[ii];
#pragma omp parallel
// 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 master taskloop simd
for(ii=0;(ii<10);ii-=0)
c[ii]=a[ii];
#pragma omp parallel
// 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 master taskloop simd
for(ii=0;ii>10;(ii+=0))
c[ii]=a[ii];
#pragma omp parallel
// 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 master taskloop simd
for(ii=0;ii<10;(ii)=(1-1)+(ii))
c[ii]=a[ii];
#pragma omp parallel
// 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 master taskloop simd
for((ii=0);ii>10;(ii-=0))
c[ii]=a[ii];
#pragma omp parallel
// 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 master taskloop simd
for(ii=0;(ii<10);(ii-=0))
c[ii]=a[ii];
#pragma omp parallel
// expected-note@+2 {{defined as firstprivate}}
// expected-error@+2 {{loop iteration variable in the associated loop of 'omp master taskloop simd' directive may not be firstprivate, predetermined as linear}}
#pragma omp master taskloop simd firstprivate(ii)
for(ii=0;ii<10;ii++)
c[ii]=a[ii];
#pragma omp parallel
#pragma omp master taskloop simd linear(ii)
for(ii=0;ii<10;ii++)
c[ii]=a[ii];
// omp4-note@+3 {{defined as private}}
// omp4-error@+3 {{loop iteration variable in the associated loop of 'omp master taskloop simd' directive may not be private, predetermined as linear}}
#pragma omp parallel
#pragma omp master taskloop simd private(ii)
for(ii=0;ii<10;ii++)
c[ii]=a[ii];
// omp4-note@+3 {{defined as lastprivate}}
// omp4-error@+3 {{loop iteration variable in the associated loop of 'omp master taskloop simd' directive may not be lastprivate, predetermined as linear}}
#pragma omp parallel
#pragma omp master taskloop simd lastprivate(ii)
for(ii=0;ii<10;ii++)
c[ii]=a[ii];
#pragma omp parallel
{
// expected-error@+2 {{loop iteration variable in the associated loop of 'omp master taskloop simd' directive may not be threadprivate or thread local, predetermined as linear}}
#pragma omp master taskloop simd
for(sii=0;sii<10;sii+=1)
c[sii]=a[sii];
}
#pragma omp parallel
{
#pragma omp master taskloop simd
for(reg0=0;reg0<10;reg0+=1)
c[reg0]=a[reg0];
}
#pragma omp parallel
{
#pragma omp master taskloop simd
for(reg=0;reg<10;reg+=1)
c[reg]=a[reg];
}
#pragma omp parallel
{
#pragma omp master taskloop simd
for(globalii=0;globalii<10;globalii+=1)
c[globalii]=a[globalii];
}
#pragma omp parallel
{
#pragma omp master taskloop simd collapse(2)
for(ii=0;ii<10;ii+=1)
for(globalii=0;globalii<10;globalii+=1)
c[globalii]+=a[globalii]+ii;
}
#pragma omp parallel
// omp4-error@+2 {{statement after '#pragma omp master taskloop simd' must be a for loop}}
#pragma omp master taskloop simd
for(auto&item:a){
item=item+1;
}
#pragma omp parallel
// expected-note@+3 {{loop step is expected to be positive due to this condition}}
// expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
#pragma omp master taskloop simd
for(unsignedi=9;i<10;i--){
c[i]=a[i]+b[i];
}
int(*lb)[4]=nullptr;
#pragma omp parallel
#pragma omp master taskloop simd
for(int(*p)[4]=lb;p<lb+8;++p){
}
#pragma omp parallel
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(GoodIter&I=begin;I<end;++I)
++I;
#pragma omp parallel
#pragma omp master taskloop simd
for(GoodIterI=begin;I>=end;--I)
++I;
#pragma omp parallel
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(GoodIterI(begin);I<end;++I)
++I;
#pragma omp parallel
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(GoodIterI(nullptr);I<end;++I)
++I;
#pragma omp parallel
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(GoodIterI(0);I<end;++I)
++I;
#pragma omp parallel
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(GoodIterI(1,2);I<end;++I)
++I;
#pragma omp parallel
#pragma omp master taskloop simd
for(begin=GoodIter(0);begin<end;++begin)
++begin;
// expected-error@+4 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
// expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
#pragma omp parallel
#pragma omp master taskloop simd
for(begin=begin0;begin<end;++begin)
++begin;
#pragma omp parallel
// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(++begin;begin<end;++begin)
++begin;
#pragma omp parallel
#pragma omp master taskloop simd
for(begin=end;begin<end;++begin)
++begin;
#pragma omp parallel
// omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
#pragma omp master taskloop simd
for(GoodIterI=begin;I-I;++I)
++I;
#pragma omp parallel
// omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
#pragma omp master taskloop simd
for(GoodIterI=begin;begin<end;++I)
++I;
#pragma omp parallel
// omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
#pragma omp master taskloop simd
for(GoodIterI=begin;!I;++I)
++I;
#pragma omp parallel
// expected-note@+3 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
#pragma omp master taskloop simd
for(GoodIterI=begin;I>=end;I=I+1)
++I;
#pragma omp parallel
#pragma omp master taskloop simd
for(GoodIterI=begin;I>=end;I=I-1)
++I;
#pragma omp parallel
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
#pragma omp master taskloop simd
for(GoodIterI=begin;I>=end;I=-I)
++I;
#pragma omp parallel
// expected-note@+3 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
#pragma omp master taskloop simd
for(GoodIterI=begin;I>=end;I=2+I)
++I;
#pragma omp parallel
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
#pragma omp master taskloop simd
for(GoodIterI=begin;I>=end;I=2-I)
++I;
// In the following example, we cannot update the loop variable using '+='
// expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
#pragma omp parallel
#pragma omp master taskloop simd
for(Iter0I=begin0;I<end0;++I)
++I;
#pragma omp parallel
// Initializer is constructor without params.
// expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(Iter0I;I<end0;++I)
++I;
Iter1begin1,end1;
// expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
// expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
#pragma omp parallel
#pragma omp master taskloop simd
for(Iter1I=begin1;I<end1;++I)
++I;
#pragma omp parallel
// expected-note@+3 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
#pragma omp master taskloop simd
for(Iter1I=begin1;I>=end1;++I)
++I;
#pragma omp parallel
// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
// expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
// Initializer is constructor with all default params.
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp master taskloop simd
for(Iter1I;I<end1;++I){
}
return0;
}
template<typenameIT,intST>
classTC{
public:
intdotest_lt(ITbegin,ITend){
#pragma omp parallel
// expected-note@+3 {{loop step is expected to be positive due to this condition}}
// expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
#pragma omp master taskloop simd
for(ITI=begin;I<end;I=I+ST){
++I;
}
#pragma omp parallel
// expected-note@+3 {{loop step is expected to be positive due to this condition}}
// expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
#pragma omp master taskloop simd
for(ITI=begin;I<=end;I+=ST){
++I;
}
#pragma omp parallel
#pragma omp master taskloop simd
for(ITI=begin;I<end;++I){
++I;
}
}
staticITstep(){
returnIT(ST);
}
};
template<typenameIT,intST=0>
intdotest_gt(ITbegin,ITend){
#pragma omp parallel
// expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
#pragma omp master taskloop simd
for(ITI=begin;I>=end;I=I+ST){
++I;
}
#pragma omp parallel
// expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
#pragma omp master taskloop simd
for(ITI=begin;I>=end;I+=ST){
++I;
}
#pragma omp parallel
// expected-note@+3 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
#pragma omp master taskloop simd
for(ITI=begin;I>=end;++I){
++I;
}
#pragma omp parallel
#pragma omp master taskloop simd
for(ITI=begin;I<end;I+=TC<int,ST>::step()){
++I;
}
}
voidtest_with_template(){
GoodIterbegin,end;
TC<GoodIter,100>t1;
TC<GoodIter,-100>t2;
t1.dotest_lt(begin,end);
t2.dotest_lt(begin,end);// expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
dotest_gt(begin,end);// expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
dotest_gt<unsigned,10>(0,100);// expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
}
voidtest_loop_break(){
constintN=100;
floata[N],b[N],c[N];
#pragma omp parallel
#pragma omp master taskloop simd
for(inti=0;i<10;i++){
c[i]=a[i]+b[i];
for(intj=0;j<10;++j){
if(a[i]>b[j])
break;// OK in nested loop
}
switch(i){
case1:
b[i]++;
break;
default:
break;
}
if(c[i]>10)
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
#pragma omp master taskloop 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
#pragma omp master taskloop 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}}