re PR fortran/91566 (ICE in gfc_constructor_copy, at fortran/constructor.c:103)

2019-09-13  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/91566
	* simplify.c (gfc_simplify_merge): Need to simplify expression
	after insertation of parenthesis.

2019-09-13  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/91566
	* gfortran.dg/pr91566.f90:

From-SVN: r275704
This commit is contained in:
Steven G. Kargl 2019-09-13 20:19:40 +00:00
parent c28712beb4
commit 81e87db49d
4 changed files with 32 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2019-09-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91566
* simplify.c (gfc_simplify_merge): Need to simplify expression
after insertation of parenthesis.
2019-09-13 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR fortran/91716

View File

@ -4780,8 +4780,13 @@ gfc_simplify_merge (gfc_expr *tsource, gfc_expr *fsource, gfc_expr *mask)
gfc_constructor *tsource_ctor, *fsource_ctor, *mask_ctor;
if (mask->expr_type == EXPR_CONSTANT)
return gfc_get_parentheses (gfc_copy_expr (mask->value.logical
? tsource : fsource));
{
result = gfc_copy_expr (mask->value.logical ? tsource : fsource);
/* Parenthesis is needed to get lower bounds of 1. */
result = gfc_get_parentheses (result);
gfc_simplify_expr (result, 1);
return result;
}
if (!mask->rank || !is_constant_array_expr (mask)
|| !is_constant_array_expr (tsource) || !is_constant_array_expr (fsource))

View File

@ -1,3 +1,8 @@
2019-09-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91566
* gfortran.dg/pr91566.f90:
2019-09-13 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR fortran/91716

View File

@ -0,0 +1,14 @@
! { dg-do compile }
! Code contributed by Gerhard Steinmetz
program p
call q
call r
end program p
subroutine q
print *, -merge([3,4], 0, [.false.,.true.])
end
subroutine r
print *, 2 + merge([3,4], 0, [.false.,.true.])
end