aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/coarray.cc
diff options
context:
space:
mode:
authorAndre Vehreschild <vehre@gcc.gnu.org>2025-06-27 15:31:21 +0200
committerAndre Vehreschild <vehre@gcc.gnu.org>2025-07-01 13:02:13 +0200
commitee31ab9b1950b7f47f030bda231ace34d187ae26 (patch)
tree6b5babd37aadc245c196ad5b67603dadb771fe17 /gcc/fortran/coarray.cc
parentd0561362e90a97a89358d8ca792208555cb3f87d (diff)
downloadgcc-ee31ab9b1950b7f47f030bda231ace34d187ae26.zip
gcc-ee31ab9b1950b7f47f030bda231ace34d187ae26.tar.gz
gcc-ee31ab9b1950b7f47f030bda231ace34d187ae26.tar.bz2
Fortran: Ensure arguments in coarray call get unique components in add_data [PR120847]
PR fortran/120847 gcc/fortran/ChangeLog: * coarray.cc (check_add_new_comp_handle_array): Make the count of components static to be able to create more than one. Create an array component only for array expressions. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/coindexed_7.f90: New test.
Diffstat (limited to 'gcc/fortran/coarray.cc')
-rw-r--r--gcc/fortran/coarray.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/fortran/coarray.cc b/gcc/fortran/coarray.cc
index 2f067f8..6914697 100644
--- a/gcc/fortran/coarray.cc
+++ b/gcc/fortran/coarray.cc
@@ -503,7 +503,7 @@ check_add_new_comp_handle_array (gfc_expr *e, gfc_symbol *type,
gfc_symbol *add_data)
{
gfc_component *comp;
- int cnt = -1;
+ static int cnt = -1;
gfc_symtree *caller_image;
gfc_code *pre_code = caf_accessor_prepend;
bool static_array_or_scalar = true;
@@ -566,7 +566,7 @@ check_add_new_comp_handle_array (gfc_expr *e, gfc_symbol *type,
else
{
comp->initializer = gfc_copy_expr (e);
- if (e_attr.dimension)
+ if (e_attr.dimension && e->rank)
{
comp->attr.dimension = 1;
comp->as = get_arrayspec_from_expr (e);