Commit 7a85da89 by Andre Vehreschild

re PR fortran/67538 (ICE with invalid source allocation)

gcc/fortran/ChangeLog:

2016-04-04  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/67538
	* resolve.c (resolve_allocate_expr): Emit error message when no
	array spec and no array valued source= expression is given in an
	F2008 allocate() for an array to allocate.

gcc/testsuite/ChangeLog:

2016-04-04  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/67538
	* gfortran.dg/allocate_with_source_19.f08: New test.

From-SVN: r234714
parent de517e64
2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org> 2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/67538
* resolve.c (resolve_allocate_expr): Emit error message when no
array spec and no array valued source= expression is given in an
F2008 allocate() for an array to allocate.
2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/65795 PR fortran/65795
* trans-array.c (gfc_array_allocate): When the array is a coarray, * trans-array.c (gfc_array_allocate): When the array is a coarray,
do not nullyfing its allocatable components in array_allocate, because do not nullyfing its allocatable components in array_allocate, because
......
...@@ -7217,7 +7217,15 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec) ...@@ -7217,7 +7217,15 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec)
if (!gfc_notify_std (GFC_STD_F2008, "Array specification required " if (!gfc_notify_std (GFC_STD_F2008, "Array specification required "
"in ALLOCATE statement at %L", &e->where)) "in ALLOCATE statement at %L", &e->where))
goto failure; goto failure;
*array_alloc_wo_spec = true; if (code->expr3->rank != 0)
*array_alloc_wo_spec = true;
else
{
gfc_error ("Array specification or array-valued SOURCE= "
"expression required in ALLOCATE statement at %L",
&e->where);
goto failure;
}
} }
else else
{ {
......
2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org> 2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/67538
* gfortran.dg/allocate_with_source_19.f08: New test.
2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/65795 PR fortran/65795
* gfortran.dg/coarray_allocate_6.f08: New test. * gfortran.dg/coarray_allocate_6.f08: New test.
......
! { dg-do compile }
! { dg-options -std=f2008 }
! Contributed by mrestelli@gmail.com
! Check that instead of an ICE the error message is emitted.
module m
implicit none
contains
subroutine s()
real, allocatable :: x(:)
real :: y
y = 5.0
! x either needs an array spec, or y needs to be an array.
allocate( x , source=y ) ! { dg-error "Array specification or array-valued SOURCE= expression required in ALLOCATE statement" }
end subroutine s
end module m
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