backport: re PR fortran/83093 (ICE in fold_convert_loc, at fold-const.c:2266)

2018-01-10 Steven G. Kargl  <kargl@gcc.gnu.org>

	Backport from trunk
	PR fortran/83093
	* resolve.c (resolve_charlen): Check the type of cl->length
	after resolution.

2018-01-10  Steven G. Kargl  <kargl@gcc.gnu.org>

	Backport from trunk
	PR fortran/83093
	* gfortran.dg/allocate_with_typespec_7.f90: New test.

From-SVN: r256459
This commit is contained in:
Steven G. Kargl 2018-01-10 22:35:00 +00:00
parent ee30b822e5
commit 7a760f1977
4 changed files with 35 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
Backport from trunk
PR fortran/83093
* resolve.c (resolve_charlen): Check the type of cl->length
after resolution.
2018-01-10 Steven G. Kargl <kargl@kgcc.gnu.org>
Backport r254555 from trunk

View File

@ -11458,10 +11458,17 @@ resolve_charlen (gfc_charlen *cl)
specification_expr = saved_specification_expr;
return false;
}
/* cl->length has been resolved. It should have an integer type. */
if (cl->length && cl->length->ts.type != BT_INTEGER)
{
gfc_error ("Scalar INTEGER expression expected at %L",
&cl->length->where);
return false;
}
}
else
{
if (!resolve_index_expr (cl->length))
{
specification_expr = saved_specification_expr;

View File

@ -1,3 +1,9 @@
2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
Backport from trunk
PR fortran/83093
* gfortran.dg/allocate_with_typespec_7.f90: New test.
2018-01-10 Steven G. Kargl <kargl@kgcc.gnu.org>
Backport r254555 from trunk

View File

@ -0,0 +1,14 @@
! { dg-do compile }
! PR Fortran/83093
! Contributed by Gerhard Steinmetz <gscfq at t-online dot de>
program p
integer, parameter :: n(2) = [1,2]
real :: x = 2
character(:), allocatable :: z, zz, zzz
character(:), allocatable :: y, yy
allocate (character(a) :: z) ! { dg-error "Scalar INTEGER expression" }
allocate (character(x) :: zz) ! { dg-error "Scalar INTEGER expression" }
allocate (character((1.0)) :: z) ! { dg-error "Scalar INTEGER expression" }
allocate (character(y) :: y) ! { dg-error "Scalar INTEGER expression" }
allocate (character(n(1:2)) :: y)! { dg-error "Scalar INTEGER expression" }
end