Hi Yuao,
Yuao Ma wrote:
The following is might be an issue in the caller, but nonetheless
it fails with conditionals (gfc_match_omp_clauses [openmp.cc:2611]
calling gfc_extract_int) - while it works with arithmetic expressions
and named constants. (Compile with '-fopenmp'.)
...
!$omp do collapse( (1 > 0 ? 1 : 2) ) ! Fails with: 'Constant expression
required'
The two issues above can be resolved by adding the following code to
`gfc_match_dupl_check` in openmp.cc.
if (expr) gfc_simplify_expr (*expr, 0);
...
I am unsure if this is the most appropriate place to simplify.
I am very much in favor of deferring it. Plus: I am wondering
whether it is generally okay to just simplify it here – or whether
it has to be delayed to a later resolving stage. For constants, when
used in the executable part, it is probably okay – but in the
specification part, it likely breaks.
If we need to defer it, then the check would be later in
resolve_omp_clauses, but we then have to save the expression
(gfc_expr*) instead of a flag ('bool', 'int …:1').
In any case, that's something unrelated to the patch itself.
* * *
Subject: [PATCH] fortran: implement conditional expression for fortran 2023
This patch adds support for conditional expressions in Fortran 2023 for a
limited set of types (logical, numerical), and also includes limited support
for conditional arguments without `.nil.` support.
LGTM. Thanks!
Tobias