From 2f11881446ab72f0e85eedb8391ae47cd89d3244 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Schl=C3=BCter?= Date: Thu, 12 Apr 2007 18:53:26 +0200 Subject: [PATCH] arith.c (gfc_arith_uplus): Rename to ... * arith.c (gfc_arith_uplus): Rename to ... (gfc_arith_identity): ... this. (gfc_parentheses): New function. (gfc_uplus): Adapt to renamed function. * arith.h (gfc_parentheses): Add prototype. * expr.c (gfc_copy_expr): Deal with INTRINSIC_PARENTHESES. (simplifiy_intrinsic_op): Treat INTRINSIC_UPLUS separately from INTRINSIC_PARENTHESES. From-SVN: r123750 --- gcc/fortran/ChangeLog | 11 +++++++++++ gcc/fortran/arith.c | 14 +++++++++++--- gcc/fortran/arith.h | 1 + gcc/fortran/expr.c | 6 +++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3bc5b39..1ea9178 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,14 @@ +2007-04-12 Tobias Schlüter + + * arith.c (gfc_arith_uplus): Rename to ... + (gfc_arith_identity): ... this. + (gfc_parentheses): New function. + (gfc_uplus): Adapt to renamed function. + * arith.h (gfc_parentheses): Add prototype. + * expr.c (gfc_copy_expr): Deal with INTRINSIC_PARENTHESES. + (simplifiy_intrinsic_op): Treat INTRINSIC_UPLUS separately from + INTRINSIC_PARENTHESES. + 2007-04-12 Tobias Burnus PR fortran/31472 diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c index e6c2d0f..8c995ea 100644 --- a/gcc/fortran/arith.c +++ b/gcc/fortran/arith.c @@ -595,10 +595,11 @@ check_result (arith rc, gfc_expr *x, gfc_expr *r, gfc_expr **rp) /* It may seem silly to have a subroutine that actually computes the unary plus of a constant, but it prevents us from making exceptions - in the code elsewhere. */ + in the code elsewhere. Used for unary plus and parenthesized + expressions. */ static arith -gfc_arith_uplus (gfc_expr *op1, gfc_expr **resultp) +gfc_arith_identity (gfc_expr *op1, gfc_expr **resultp) { *resultp = gfc_copy_expr (op1); return ARITH_OK; @@ -1763,9 +1764,16 @@ eval_intrinsic_f3 (gfc_intrinsic_op operator, gfc_expr * +gfc_parentheses (gfc_expr *op) +{ + return eval_intrinsic_f2 (INTRINSIC_PARENTHESES, gfc_arith_identity, + op, NULL); +} + +gfc_expr * gfc_uplus (gfc_expr *op) { - return eval_intrinsic_f2 (INTRINSIC_UPLUS, gfc_arith_uplus, op, NULL); + return eval_intrinsic_f2 (INTRINSIC_UPLUS, gfc_arith_identity, op, NULL); } diff --git a/gcc/fortran/arith.h b/gcc/fortran/arith.h index 04d37dc..6a45108 100644 --- a/gcc/fortran/arith.h +++ b/gcc/fortran/arith.h @@ -43,6 +43,7 @@ int gfc_compare_expr (gfc_expr *, gfc_expr *); int gfc_compare_string (gfc_expr *, gfc_expr *); /* Constant folding for gfc_expr trees. */ +gfc_expr *gfc_parentheses (gfc_expr * op); gfc_expr *gfc_uplus (gfc_expr * op); gfc_expr *gfc_uminus (gfc_expr * op); gfc_expr *gfc_add (gfc_expr *, gfc_expr *); diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index d3f57172..f2064fb 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -465,6 +465,7 @@ gfc_copy_expr (gfc_expr *p) switch (q->value.op.operator) { case INTRINSIC_NOT: + case INTRINSIC_PARENTHESES: case INTRINSIC_UPLUS: case INTRINSIC_UMINUS: q->value.op.op1 = gfc_copy_expr (p->value.op.op1); @@ -771,8 +772,11 @@ simplify_intrinsic_op (gfc_expr *p, int type) switch (p->value.op.operator) { - case INTRINSIC_UPLUS: case INTRINSIC_PARENTHESES: + result = gfc_parentheses (op1); + break; + + case INTRINSIC_UPLUS: result = gfc_uplus (op1); break; -- 2.7.4