issue with OpenMP if clause

Hi

It seems that pgc++ (15.7) has an issue with a leading exclamation mark in an if clause of an OpenMP construct:

  const bool nothing_to_do = true;
  std::vector<int> numbers(1024);
#ifdef _OPENMP
#pragma omp parallel for default(none) if( !nothing_to_do ) shared(numbers) 
  for(size_t i=0;i<numbers.size();++i){
    numbers[i] = i*i; 
  }
#endif

results in the following compile error:

main.C:
"main.C", line 39: error: expected an identifier
  #pragma omp parallel for default(none) if( !nothing_to_do ) shared(numbers)
                                             ^

"main.C", line 39: error: invalid text in pragma
  #pragma omp parallel for default(none) if( !nothing_to_do ) shared(numbers)
                                              ^

"main.C", line 39: error: extra text after expected end of preprocessing
          directive
  #pragma omp parallel for default(none) if( !nothing_to_do ) shared(numbers)
                                                            ^

"main.C", line 36: error: variable "nothing_to_do" was declared but never
          referenced
    const bool nothing_to_do = true;

However, changing the if clause to

if(true && !nothing_to_do)

compiles without any problems. gcc doesn’t have a problem with either expression and probably the OpenMP standard requires any boolean expression to be supported.

Thanks,
LS

Thanks LS. I’m not sure how we missed this.

I have created a problem report (FS#21969 - Using a not operator in an OpenMP or OpenACC “if” clause causes a syntax error with pgc++/pgcpp ) and sent it off to engineering for further investigation.

Best Regards,
Mat

TPR 21969 - UF: Using a not operator in an OpenMP or OpenACC “if” clause causes a syntax error with pgc++/pgcpp

has been fixed in the current 16.7 release.

Thanks for the submission.

dave