On Fri, Sep 30, 2022 at 12:41:19PM +0200, Tobias Burnus wrote: > While has_device_addr has been implemented (in GCC 12), updating > use_device_ptr for Fortran was missed. > > This patch fixes it: Removing the restrictions and mapping to > has_device_addr where applicable. > > For use_device_ptr something similar was done, albeit I think > this has no semantic effect. > > And 'device(omp_initial_device)' printed a warning in Fortran. > (BTW: C/C++ silently accepts any negative value.)
I think that is what the standard wants. E.g. in 5.2 device Clause chapter, there is just "If the device_num device-modifier is specified and target-offload-var is not mandatory, device-description must evaluate to a conforming device number." restriction, which is something that can't be checked at compile time, you don't know if target-offload-var is mandatory or not. > if (omp_clauses->device) > - resolve_nonnegative_int_expr (omp_clauses->device, "DEVICE"); > + { > + resolve_scalar_int_expr (omp_clauses->device, "DEVICE"); > + /* omp_initial_device == 1, omp_invalid_device = -4 (in GCC). */ > + if (omp_clauses->device->expr_type == EXPR_CONSTANT > + && omp_clauses->device->ts.type == BT_INTEGER > + && mpz_cmp_si (omp_clauses->device->value.integer, -1) < 0 > + && mpz_cmp_si (omp_clauses->device->value.integer, -4) != 0) > + gfc_warning (0, > + "INTEGER expression of DEVICE clause at %L must be non-" > + "negative or omp_initial_device or omp_invalid_device", > + &omp_clauses->device->where); > + } So I think we should just resolve_scalar_int_expr and be done with that. Otherwise LGTM. Jakub