https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113904

            Bug ID: 113904
           Summary: [OpenMP][5.0][5.1] Dynamic context selector
                    'user={condition(expr)}' not handled
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, openmp, rejects-valid, wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: parras at gcc dot gnu.org, sandra at gcc dot gnu.org
  Target Milestone: ---

There are two related problems, leading currently to either
  wrong-code (Fortran - alias accepts-invalid OpenMP 5.0)
  or rejects-valid OpenMP 5.1 (C/C++).

* Fortran accepts non constant values - but the ME does not handle them.
  → OpenMP 5.1 feature supported for parsing but not in the ME
  → wrong-code

* C/C++ rejects non-const values
  → Rejecting valid 5.1 code



gfortran happily accepts non constant values - while gcc/g++ reject them

test.c:22:58: error: the value of 'foo_use_var2' is not usable in a constant
expression
   22 | #pragma omp declare variant (var2)
match(user={condition(foo_use_var2)})


While OpenMP 5.0 only permits
   The user selector set defines the condition selector that provides
   additional user-defined conditions.

   C: The condition(boolean-expr) selector defines a constant expression
   that must evaluate to true for the selector to be true.

   C++: The condition(boolean-expr) selector defines a constexpr
   expression that must evaluate to true for the selector to be true.

   Fortran: The condition(logical-expr) selector defines a constant
   expression that must evaluate to true for the selector to be true.


Since OpenMP 5.1:
  The condition selector contains a single trait-property-expression
  that must evaluate to true for the selector to be true.
  Any non-constant expression that is evaluated to determine the
  suitability of a variant is evaluated according to the data state
  trait in the dynamic trait set of the OpenMP context.
  The user selector set is dynamic if the condition selector is present
  and the expression in the condition selector is not a constant
  expression; otherwise, it is static.

Reply via email to