Issue 147336
Summary Clang: Clang error for metadirective with multiple when clauses and no otherwise
Labels clang
Assignees
Reporter Ritanya-B-Bharadwaj
    This commit - https://github.com/llvm/llvm-project/pull/127113 fixes the "expected _expression_" error caused by a missing implicit otherwise clause in metadirective.
However, the issue still persists when multiple when clauses are present without an explicit default.
For example:
```
#include <stdio.h>
#include <omp.h>

#if defined(OPENMP_THREAD)
#define OMP_MODEL_THREADS       1
#define OMP_MODEL_TARGET        0
#elif defined(OPENMP_TARGET)
#define OMP_MODEL_THREADS       0
#define OMP_MODEL_TARGET        1
#else
#define OMP_MODEL_THREADS       0
#define OMP_MODEL_TARGET        0
#endif

double a,x[1000],y[1000],z[1000];
int good_with_default()
{
  int i;

// Routine with "otherwise" clause compiles clean.
#pragma omp metadirective \
 when(user={condition(OMP_MODEL_THREADS)}:parallel for simd) \
 when(user={condition(OMP_MODEL_TARGET)}: target teams distribute parallel for simd) \
     otherwise(simd)

  for (i=0;i<1000;i++)
    {
 z[i]=a*x[i]+y[i];
    }
  return 0;
}


int error_without_default()
{
  int i;
  // error: expected _expression_
#pragma omp metadirective \
 when(user={condition(OMP_MODEL_THREADS)}:parallel for simd) \
 when(user={condition(OMP_MODEL_TARGET)}: target teams distribute parallel for simd)

  for (i=0;i<1000;i++)
    {
      z[i]=a*x[i]+y[i];
    }
 return 0;
}
```

Output 
```
<source>:40:89: error: expected _expression_
   40 |      when(user={condition(OMP_MODEL_TARGET)}: target teams distribute parallel for simd)
      | ^
1 error generated.
Compiler returned: 1
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to