Skip to content

Clang: Clang error for metadirective with multiple when clauses and no otherwise #147336

@Ritanya-B-Bharadwaj

Description

@Ritanya-B-Bharadwaj

This commit - #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_otherwise()
{
  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_otherwise()
{
  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"clang:openmpOpenMP related changes to Clang

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions