https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118321
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tobias Burnus <bur...@gcc.gnu.org>: https://gcc.gnu.org/g:f5409d71e2ec8cdcc674b312dd4c115bb3626eba commit r15-6976-gf5409d71e2ec8cdcc674b312dd4c115bb3626eba Author: Tobias Burnus <tbur...@baylibre.com> Date: Thu Jan 16 22:39:03 2025 +0100 Fortran/OpenMP: Fix declare_variant's 'adjust_args' mishandling with return by reference [PR118321] declare_variant's 'adjust_args' clause references the arguments in the middle end by the argument position; this has to account for hidden arguments that are inserted before due to return by reference, as done in this commit. PR fortran/118321 gcc/fortran/ChangeLog: * trans-openmp.cc (gfc_trans_omp_declare_variant): Honor hidden arguments for append_arg's need_device_ptr. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/adjust-args-12.f90: New test.