<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/147336>147336</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang: Clang error for metadirective with multiple when clauses and no otherwise
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Ritanya-B-Bharadwaj
</td>
</tr>
</table>
<pre>
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
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzcVlFv4zYM_jXMC9FAlpLYefCDkzS7h91adH0vFIuJdZAtQ5LbdL9-kOzm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