aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2022-09-15 22:06:53 +0200
committerHarald Anlauf <anlauf@gmx.de>2022-09-15 22:12:47 +0200
commit7bd4deb2a7c1394550610ab27507d1ed2af817c2 (patch)
tree98c545975b5798a324b184fd7bc9b89c55aec1e2
parent6248f4ff67502c88d92f55fa5ea5996937220e5c (diff)
downloadgcc-7bd4deb2a7c1394550610ab27507d1ed2af817c2.zip
gcc-7bd4deb2a7c1394550610ab27507d1ed2af817c2.tar.gz
gcc-7bd4deb2a7c1394550610ab27507d1ed2af817c2.tar.bz2
Fortran: error recovery for bad deferred character length assignment [PR104314]
gcc/fortran/ChangeLog: PR fortran/104314 * resolve.cc (deferred_op_assign): Do not try to generate temporary for deferred character length assignment if types do not agree. gcc/testsuite/ChangeLog: PR fortran/104314 * gfortran.dg/pr104314.f90: New test. Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
-rw-r--r--gcc/fortran/resolve.cc1
-rw-r--r--gcc/testsuite/gfortran.dg/pr104314.f909
2 files changed, 10 insertions, 0 deletions
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index ca11475..ae7ebb6 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -11803,6 +11803,7 @@ deferred_op_assign (gfc_code **code, gfc_namespace *ns)
if (!((*code)->expr1->ts.type == BT_CHARACTER
&& (*code)->expr1->ts.deferred && (*code)->expr1->rank
+ && (*code)->expr2->ts.type == BT_CHARACTER
&& (*code)->expr2->expr_type == EXPR_OP))
return false;
diff --git a/gcc/testsuite/gfortran.dg/pr104314.f90 b/gcc/testsuite/gfortran.dg/pr104314.f90
new file mode 100644
index 0000000..510ded0
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr104314.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/104314 - ICE in deferred_op_assign
+! Contributed by G.Steinmetz
+
+program p
+ character(:), allocatable :: c(:)
+ c = ['123']
+ c = c == c ! { dg-error "Cannot convert" }
+end