public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9202] Fortran: Fix deferred character lengths in array constructors [PR98517].
@ 2021-01-25 10:34 Paul Thomas
0 siblings, 0 replies; only message in thread
From: Paul Thomas @ 2021-01-25 10:34 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:504159b44da4adbea75047da0ad06c6d4223caec
commit r9-9202-g504159b44da4adbea75047da0ad06c6d4223caec
Author: Paul Thomas <pault@gcc.gnu.org>
Date: Mon Jan 25 10:27:51 2021 +0000
Fortran: Fix deferred character lengths in array constructors [PR98517].
2021-01-25 Steve Kargl <kargl@gcc.gnu.org>
gcc/fortran
PR fortran/98517
* resolve.c (resolve_charlen): Check that length expression is
present before testing for scalar/integer..
gcc/testsuite/
PR fortran/98517
* gfortran.dg/charlen_18.f90 : New test.
(cherry picked from commit c6b0e33febbf73abfcc2bb0e28f0b62afe3b0f2a)
Diff:
---
gcc/fortran/resolve.c | 3 ++-
gcc/testsuite/gfortran.dg/charlen_18.f90 | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 8ddef4f682b..6b308276e49 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -12042,7 +12042,8 @@ resolve_charlen (gfc_charlen *cl)
}
/* cl->length has been resolved. It should have an integer type. */
- if (cl->length->ts.type != BT_INTEGER || cl->length->rank != 0)
+ if (cl->length
+ && (cl->length->ts.type != BT_INTEGER || cl->length->rank != 0))
{
gfc_error ("Scalar INTEGER expression expected at %L",
&cl->length->where);
diff --git a/gcc/testsuite/gfortran.dg/charlen_18.f90 b/gcc/testsuite/gfortran.dg/charlen_18.f90
new file mode 100644
index 00000000000..5ad287448b4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/charlen_18.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-fdec-structure" }
+!
+! Check fix for PR98517
+!
+! Contributed by Eric Reischer <emr-gnu@hev.psu.edu>
+!
+ SUBROUTINE TEST_BUG
+ IMPLICIT NONE
+
+ CHARACTER*(*) DEF_VAL
+ PARAMETER (DEF_VAL = 'ABCDEFGH')
+
+ STRUCTURE /SOME_STRUCT/
+ CHARACTER*64 SOME_VAR /DEF_VAL/
+ END STRUCTURE
+
+ END
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-25 10:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 10:34 [gcc r9-9202] Fortran: Fix deferred character lengths in array constructors [PR98517] Paul Thomas
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).