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.
This commit is contained in:
parent
28229916e1
commit
c6b0e33feb
2 changed files with 20 additions and 1 deletions
|
@ -12446,7 +12446,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);
|
||||
|
|
18
gcc/testsuite/gfortran.dg/charlen_18.f90
Normal file
18
gcc/testsuite/gfortran.dg/charlen_18.f90
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue