diff options
author | Harald Anlauf <anlauf@gmx.de> | 2025-06-03 20:48:31 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2025-06-04 18:34:42 +0200 |
commit | c77dd2d7d40d4fb0d141bf61544d8a57d501f981 (patch) | |
tree | c9d581284edcfc0a44a75f2f965d4151b25b515e | |
parent | 55a920367eb34cb33a3ff22f5487a56baa1f93c6 (diff) | |
download | gcc-c77dd2d7d40d4fb0d141bf61544d8a57d501f981.zip gcc-c77dd2d7d40d4fb0d141bf61544d8a57d501f981.tar.gz gcc-c77dd2d7d40d4fb0d141bf61544d8a57d501f981.tar.bz2 |
Fortran: ICE due to missing locus with data statement for coarray [PR99838]
PR fortran/99838
gcc/fortran/ChangeLog:
* data.cc (gfc_assign_data_value): For a new initializer use the
location from the constructor as fallback.
gcc/testsuite/ChangeLog:
* gfortran.dg/coarray_data_2.f90: New test.
(cherry picked from commit 0768ec0d32f570b1db13ca41b0a1506275c44053)
-rw-r--r-- | gcc/fortran/data.cc | 8 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/coarray_data_2.f90 | 14 |
2 files changed, 21 insertions, 1 deletions
diff --git a/gcc/fortran/data.cc b/gcc/fortran/data.cc index 5c83f69..a438c26 100644 --- a/gcc/fortran/data.cc +++ b/gcc/fortran/data.cc @@ -593,7 +593,13 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index, { /* Point the container at the new expression. */ if (last_con == NULL) - symbol->value = expr; + { + symbol->value = expr; + /* For a new initializer use the location from the + constructor as fallback. */ + if (!GFC_LOCUS_IS_SET(expr->where) && con != NULL) + symbol->value->where = con->where; + } else last_con->expr = expr; } diff --git a/gcc/testsuite/gfortran.dg/coarray_data_2.f90 b/gcc/testsuite/gfortran.dg/coarray_data_2.f90 new file mode 100644 index 0000000..bda57f3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_data_2.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! { dg-additional-options "-fcoarray=lib -Warray-temporaries" } +! +! PR fortran/99838 - ICE due to missing locus with data statement for coarray +! +! Contributed by Gerhard Steinmetz + +program p + type t + integer :: a + end type + type(t) :: x(3)[*] + data x%a /1, 2, 3/ ! { dg-warning "Creating array temporary" } +end |