Commit bdd82c9b by Steven G. Kargl

re PR fortran/82367 (ICE with deferred length string allocate on non-deferred length argument)

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

	PR fortran/82367
	* resolve.c (resolve_allocate_expr): Check for NULL pointer.

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

	PR fortran/82367
	* gfortran.dg/deferred_character_18.f90: New test.

From-SVN: r256464
parent 68dc87c3
2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org> 2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/82367
* resolve.c (resolve_allocate_expr): Check for NULL pointer.
2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/83093 PR fortran/83093
* resolve.c (resolve_charlen): Check the type of cl->length * resolve.c (resolve_charlen): Check the type of cl->length
after resolution. after resolution.
......
...@@ -7484,8 +7484,13 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec) ...@@ -7484,8 +7484,13 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec)
if (code->ext.alloc.ts.type == BT_CHARACTER && !e->ts.deferred if (code->ext.alloc.ts.type == BT_CHARACTER && !e->ts.deferred
&& !UNLIMITED_POLY (e)) && !UNLIMITED_POLY (e))
{ {
int cmp = gfc_dep_compare_expr (e->ts.u.cl->length, int cmp;
code->ext.alloc.ts.u.cl->length);
if (!e->ts.u.cl->length)
goto failure;
cmp = gfc_dep_compare_expr (e->ts.u.cl->length,
code->ext.alloc.ts.u.cl->length);
if (cmp == 1 || cmp == -1 || cmp == -3) if (cmp == 1 || cmp == -1 || cmp == -3)
{ {
gfc_error ("Allocating %s at %L with type-spec requires the same " gfc_error ("Allocating %s at %L with type-spec requires the same "
......
2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/82367
* gfortran.dg/deferred_character_18.f90: New test.
2018-01-10 Martin Sebor <msebor@redhat.com> 2018-01-10 Martin Sebor <msebor@redhat.com>
PR tree-optimization/83671 PR tree-optimization/83671
......
! { dg-do compile }
! PR Fortran/82367
! Contributed by Walter Spector <w6ws at earthlink dot net>
module cls_allocmod
implicit none
contains
subroutine cls_alloc (n, str)
integer, intent(in) :: n
character(*), allocatable, intent(out) :: str
! Note: Star ^ should have been a colon (:)
allocate (character(n)::str)
end subroutine
end module
program cls
use cls_allocmod
implicit none
character(:), allocatable :: s
call cls_alloc(42, s) ! { dg-error "allocatable or pointer dummy argument" }
print *, 'string len =', len(s)
end program
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment