[Committed] PR fortran/91553 -- simplification of constants needs to check for parenthesis
diff mbox series

Message ID 20190911184103.GA10456@troutmask.apl.washington.edu
State New
Headers show
Series
  • [Committed] PR fortran/91553 -- simplification of constants needs to check for parenthesis
Related show

Commit Message

Steve Kargl Sept. 11, 2019, 6:41 p.m. UTC
Committed as obvious (once the problem is identified).

When simplification of an expression occurs, parenthesis can
be inserted.  When simplifying a constant expression, need to
check for inserted parenthesis.

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

	PR fortran/91553
	* simplify.c (gfc_convert_constant):  During conversion check if the
	constant is enclosed in parenthesis, and simplify expression.

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

	PR fortran/91553
	* gfortran.dg/pr91553.f90: New test.

Patch
diff mbox series

Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c	(revision 275651)
+++ gcc/fortran/simplify.c	(working copy)
@@ -8503,6 +8503,12 @@  gfc_convert_constant (gfc_expr *e, bt type, int kind)
 	    {
 	      if (c->expr->expr_type == EXPR_ARRAY)
 		tmp = gfc_convert_constant (c->expr, type, kind);
+	      else if (c->expr->expr_type == EXPR_OP
+		       && c->expr->value.op.op == INTRINSIC_PARENTHESES)
+		{
+		  gfc_simplify_expr (c->expr, 1);
+		  tmp = f (c->expr, kind);
+		}
 	      else
 		tmp = f (c->expr, kind);
 	    }
Index: gcc/testsuite/gfortran.dg/pr91553.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr91553.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr91553.f90	(working copy)
@@ -0,0 +1,9 @@ 
+! { dg-do run }
+! Code contributed by Gerhard Steinmetz
+program p
+   complex z(1)
+   z = (1.0, 2.0) * [real :: (3.0 + 4.0)]
+   if (real(z(1)) /= 7.) stop 1
+   if (aimag(z(1)) /= 14.) stop 2
+end