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.
}
/* 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);
--- /dev/null
+! { 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