Commit 7430df97 by Janus Weil

re PR fortran/60357 ([F08] structure constructor with unspecified values for…

re PR fortran/60357 ([F08] structure constructor with unspecified values for allocatable components)

2014-12-29  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/60357
	* array.c (check_constructor): Ignore empty expressions.
	* expr.c (check_alloc_comp_init): Check if constructor expression
	exists.
	* primary.c (build_actual_constructor): Warn for absent alloc-comp
	initializers in pre-2008 standards.

2014-12-29  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/60357
	* gfortran.dg/alloc_comp_constructor_7.f90: New.

From-SVN: r219098
parent 8cd2f58d
2014-12-29 Janus Weil <janus@gcc.gnu.org>
PR fortran/60357
* array.c (check_constructor): Ignore empty expressions.
* expr.c (check_alloc_comp_init): Check if constructor expression
exists.
* primary.c (build_actual_constructor): Warn for absent alloc-comp
initializers in pre-2008 standards.
2014-12-28 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/56867
......
......@@ -1309,6 +1309,9 @@ check_constructor (gfc_constructor_base ctor, bool (*check_function) (gfc_expr *
{
e = c->expr;
if (!e)
continue;
if (e->expr_type != EXPR_ARRAY)
{
if (!(*check_function)(e))
......
......@@ -2201,7 +2201,7 @@ check_alloc_comp_init (gfc_expr *e)
ctor = gfc_constructor_first (e->value.constructor);
comp; comp = comp->next, ctor = gfc_constructor_next (ctor))
{
if (comp->attr.allocatable
if (comp->attr.allocatable && ctor->expr
&& ctor->expr->expr_type != EXPR_NULL)
{
gfc_error ("Invalid initialization expression for ALLOCATABLE "
......
......@@ -2367,6 +2367,13 @@ build_actual_constructor (gfc_structure_ctor_component **comp_head,
return false;
value = gfc_copy_expr (comp->initializer);
}
else if (comp->attr.allocatable)
{
if (!gfc_notify_std (GFC_STD_F2008, "No initializer for "
"allocatable component '%s' given in the structure "
"constructor at %C", comp->name))
return false;
}
else if (!comp->attr.deferred_parameter)
{
gfc_error ("No initializer for component %qs given in the"
......
2014-12-29 Janus Weil <janus@gcc.gnu.org>
PR fortran/60357
* gfortran.dg/alloc_comp_constructor_7.f90: New.
2014-12-29 Hans-Peter Nilsson <hp@axis.com>
* gcc.dg/lto/pr59626_0.c (ASMNAME, ASMNAME2, STRING): Define.
......
! { dg-do run }
!
! PR 60357: [F08] structure constructor with unspecified values for allocatable components
!
! Contributed by Antony Lewis <antony@cosmologist.info>
Type A
integer :: X = 1
integer, allocatable :: y
integer, allocatable :: z(:)
end type
Type(A) :: Me = A(X=1)
if (allocated(Me%y)) call abort
if (allocated(Me%z)) call abort
end
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