* 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
+2007-04-12 Tobias Schlüter <tobi@gcc.gnu.org>
+
+ * 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 <burnus@net-b.de>
PR fortran/31472
/* 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;
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);
}
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 *);
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);
switch (p->value.op.operator)
{
- case INTRINSIC_UPLUS:
case INTRINSIC_PARENTHESES:
+ result = gfc_parentheses (op1);
+ break;
+
+ case INTRINSIC_UPLUS:
result = gfc_uplus (op1);
break;