public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6865] Fortran: MOLD argument to TRANSFER intrinsic having storage size zero
@ 2022-01-25 20:57 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-01-25 20:57 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:ec543c9833c2d9283c035cd8430849eb4ec04406
commit r12-6865-gec543c9833c2d9283c035cd8430849eb4ec04406
Author: Harald Anlauf <anlauf@gmx.de>
Date: Tue Jan 25 21:56:39 2022 +0100
Fortran: MOLD argument to TRANSFER intrinsic having storage size zero
gcc/fortran/ChangeLog:
PR fortran/104227
* check.cc (gfc_calculate_transfer_sizes): Fix checking of arrays
passed as MOLD argument to the TRANSFER intrinsic for having
storage size zero.
gcc/testsuite/ChangeLog:
PR fortran/104227
* gfortran.dg/transfer_check_6.f90: New test.
Diff:
---
gcc/fortran/check.cc | 2 +-
gcc/testsuite/gfortran.dg/transfer_check_6.f90 | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc
index 4fa05ee7e9b..d6c6767ae9e 100644
--- a/gcc/fortran/check.cc
+++ b/gcc/fortran/check.cc
@@ -6151,7 +6151,7 @@ gfc_calculate_transfer_sizes (gfc_expr *source, gfc_expr *mold, gfc_expr *size,
* If SIZE is present, the result is an array of rank one and size SIZE.
*/
if (result_elt_size == 0 && *source_size > 0 && !size
- && mold->expr_type == EXPR_ARRAY)
+ && (mold->expr_type == EXPR_ARRAY || mold->rank))
{
gfc_error ("%<MOLD%> argument of %<TRANSFER%> intrinsic at %L is an "
"array and shall not have storage size 0 when %<SOURCE%> "
diff --git a/gcc/testsuite/gfortran.dg/transfer_check_6.f90 b/gcc/testsuite/gfortran.dg/transfer_check_6.f90
new file mode 100644
index 00000000000..dffd0913f0d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/transfer_check_6.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/104227 - ICE virtual memory exhausted
+! Contributed by G.Steinmetz
+
+program p
+ type t
+ end type
+ type(t) :: x(2)
+ print *, transfer(1, x) ! { dg-error "shall not have storage size 0" }
+ x = transfer(1, x) ! { dg-error "shall not have storage size 0" }
+end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-25 20:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25 20:57 [gcc r12-6865] Fortran: MOLD argument to TRANSFER intrinsic having storage size zero Harald Anlauf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).