Message ID | 20191001234630.GA90127@troutmask.apl.washington.edu |
---|---|
State | New |
Headers | show |
Series | PR fortran/91784 -- Simplify EXPR_OP in conversion of constants | expand |
On 10/1/19 4:46 PM, Steve Kargl wrote: > The attached patch has been tested on x86_64-*-freebsd. > OK to commmit? OK, thanks Steve. > > In a previous patch, I specialized the simplfication of > an EXPR_OP to the case of an inserted parenthesis. This > was too restrictive as evidenced by the new test case. > The patch simply does a simplification of an expression. > > 2019-10-01 Steven G. Kargl <kargl@gcc.gnu.org> > > PR fortran/91784 > * simplify.c (gfc_convert_constant): Simplify expression if the > expression type is EXPR_OP. > > 2019-10-01 Steven G. Kargl <kargl@gcc.gnu.org> > > PR fortran/91784 > * gfortran.dg/pr91784.f90: New test. >
Index: gcc/fortran/simplify.c =================================================================== --- gcc/fortran/simplify.c (revision 276426) +++ gcc/fortran/simplify.c (working copy) @@ -8508,10 +8508,10 @@ 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) + else if (c->expr->expr_type == EXPR_OP) { - gfc_simplify_expr (c->expr, 1); + if (!gfc_simplify_expr (c->expr, 1)) + return &gfc_bad_expr; tmp = f (c->expr, kind); } else Index: gcc/testsuite/gfortran.dg/pr91784.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr91784.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr91784.f90 (working copy) @@ -0,0 +1,9 @@ +! { dg-do run } +! PR fortran/91784 +! Code originally contributed by Gerhard Steinmetz +program p + complex :: x(1) + x = (1.0, 2.0) * [real :: -(3.0 + 4.0)] + if (int(real(x(1))) /= -7) stop 1 + if (int(aimag(x(1))) /= -14) stop 2 +end