[PATCH 2/22] Coarray caf_shmem final patch set
Jerry D <[email protected]>
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.fortran |
|---|---|
| Message-ID | <[email protected]> |
Ref: https://gcc.gnu.org/pipermail/fortran/2026-February/063551.html See attached. Awaiting approval.
caf_shmem-2-of-22.patch
(text/x-patch, 4.3 KB)
From a6bd423ec389358ff0848945c10ed163bc61b9e1 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild <[email protected]> Date: Wed, 18 Jun 2025 09:21:16 +0200 Subject: [PATCH] Fortran: Small fixes of coarray routines handling and code gen. gcc/fortran/ChangeLog: * check.cc (gfc_check_image_status): Fix argument index of team= argument for correct error message. * trans-intrinsic.cc (conv_intrinsic_image_status): Team= argument is optional and is a pointer to the team handle. * trans-stmt.cc (gfc_trans_sync): Make images argument also a dereferencable pointer. But treat errmsg as a pointer to a char array like in all other functions. gcc/testsuite/ChangeLog: * gfortran.dg/coarray_sync_memory.f90: Adapt grep pattern for msg being only &msg. --- gcc/fortran/check.cc | 2 +- gcc/fortran/trans-intrinsic.cc | 6 +++++- gcc/fortran/trans-stmt.cc | 7 +++++-- gcc/testsuite/gfortran.dg/coarray_sync_memory.f90 | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index c1f1c660db0..29d9f07b81d 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -1868,7 +1868,7 @@ gfc_check_image_status (gfc_expr *image, gfc_expr *team) || !positive_check (0, image)) return false; - return !team || (scalar_check (team, 0) && team_type_check (team, 0)); + return !team || (scalar_check (team, 1) && team_type_check (team, 1)); } diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index c4d8d5c9728..cacefa3942b 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -2073,9 +2073,13 @@ conv_intrinsic_image_status (gfc_se *se, gfc_expr *expr) GFC_STAT_STOPPED_IMAGE)); } else if (flag_coarray == GFC_FCOARRAY_LIB) + /* The team is optional and therefore needs to be a pointer to the opaque + pointer. */ tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_image_status, 2, args[0], - num_args < 2 ? null_pointer_node : args[1]); + num_args < 2 + ? null_pointer_node + : gfc_build_addr_expr (NULL_TREE, args[1])); else gcc_unreachable (); diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc index 1e1179323c4..4d2ca182f80 100644 --- a/gcc/fortran/trans-stmt.cc +++ b/gcc/fortran/trans-stmt.cc @@ -1362,7 +1362,8 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type) { gfc_init_se (&argse, NULL); gfc_conv_expr_val (&argse, code->expr1); - images = argse.expr; + images = gfc_trans_force_lval (&argse.pre, argse.expr); + gfc_add_block_to_block (&se.pre, &argse.pre); } if (code->expr2) @@ -1372,6 +1373,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type) gfc_init_se (&argse, NULL); gfc_conv_expr_val (&argse, code->expr2); stat = argse.expr; + gfc_add_block_to_block (&se.pre, &argse.pre); } else stat = null_pointer_node; @@ -1384,8 +1386,9 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type) argse.want_pointer = 1; gfc_conv_expr (&argse, code->expr3); gfc_conv_string_parameter (&argse); - errmsg = gfc_build_addr_expr (NULL, argse.expr); + errmsg = argse.expr; errmsglen = fold_convert (size_type_node, argse.string_length); + gfc_add_block_to_block (&se.pre, &argse.pre); } else if (flag_coarray == GFC_FCOARRAY_LIB) { diff --git a/gcc/testsuite/gfortran.dg/coarray_sync_memory.f90 b/gcc/testsuite/gfortran.dg/coarray_sync_memory.f90 index c4e660b8cf7..0030d91257d 100644 --- a/gcc/testsuite/gfortran.dg/coarray_sync_memory.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_sync_memory.f90 @@ -14,5 +14,5 @@ end ! { dg-final { scan-tree-dump-times "_gfortran_caf_sync_memory \\(0B, 0B, 0\\);" 1 "original" } } ! { dg-final { scan-tree-dump-times "_gfortran_caf_sync_memory \\(&stat, 0B, 0\\);" 1 "original" } } -! { dg-final { scan-tree-dump-times "_gfortran_caf_sync_memory \\(0B, &&msg, 42\\);" 1 "original" } } -! { dg-final { scan-tree-dump-times "_gfortran_caf_sync_memory \\(&stat, &&msg, 42\\);" 1 "original" } } +! { dg-final { scan-tree-dump-times "_gfortran_caf_sync_memory \\(0B, &msg, 42\\);" 1 "original" } } +! { dg-final { scan-tree-dump-times "_gfortran_caf_sync_memory \\(&stat, &msg, 42\\);" 1 "original" } } -- 2.53.0