Index: trans-expr.c =================================================================== --- trans-expr.c (revision 110794) +++ trans-expr.c (working copy) @@ -925,6 +925,7 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr switch (expr->value.op.operator) { case INTRINSIC_UPLUS: + case INTRINSIC_PARENTHESES: gfc_conv_expr (se, expr->value.op.op1); return; Index: matchexp.c =================================================================== --- matchexp.c (revision 110794) +++ matchexp.c (working copy) @@ -128,6 +128,8 @@ static match match_primary (gfc_expr ** result) { match m; + gfc_expr *e; + locus where; m = gfc_match_literal_constant (result, 0); if (m != MATCH_NO) @@ -141,11 +143,13 @@ match_primary (gfc_expr ** result) if (m != MATCH_NO) return m; - /* Match an expression in parenthesis. */ + /* Match an expression in parentheses. */ + where = gfc_current_locus; + if (gfc_match_char ('(') != MATCH_YES) return MATCH_NO; - m = gfc_match_expr (result); + m = gfc_match_expr (&e); if (m == MATCH_NO) goto syntax; if (m == MATCH_ERROR) @@ -155,6 +159,26 @@ match_primary (gfc_expr ** result) if (m == MATCH_NO) gfc_error ("Expected a right parenthesis in expression at %C"); + /* Now we have the expression inside the parentheses, build the + expression pointing to it. By 7.1.7.2 the integrity of + parentheses is only conserved in numerical calculations, so we + don't bother to keep the parentheses otherwise. */ + if(!gfc_numeric_ts(&e->ts)) + *result = e; + else + { + gfc_expr *e2 = gfc_get_expr(); + + e2->expr_type = EXPR_OP; + e2->ts = e->ts; + e2->rank = e->rank; + e2->where = where; + e2->value.op.operator = INTRINSIC_PARENTHESES; + e2->value.op.op1 = e; + e2->value.op.op2 = NULL; + *result = e2; + } + if (m != MATCH_YES) { gfc_free_expr (*result); Index: dump-parse-tree.c =================================================================== --- dump-parse-tree.c (revision 110794) +++ dump-parse-tree.c (working copy) @@ -478,6 +478,9 @@ gfc_show_expr (gfc_expr * p) case INTRINSIC_NOT: gfc_status ("NOT "); break; + case INTRINSIC_PARENTHESES: + gfc_status ("parens"); + break; default: gfc_internal_error Index: gfortran.h =================================================================== --- gfortran.h (revision 110794) +++ gfortran.h (working copy) @@ -182,7 +182,7 @@ typedef enum INTRINSIC_AND, INTRINSIC_OR, INTRINSIC_EQV, INTRINSIC_NEQV, INTRINSIC_EQ, INTRINSIC_NE, INTRINSIC_GT, INTRINSIC_GE, INTRINSIC_LT, INTRINSIC_LE, INTRINSIC_NOT, INTRINSIC_USER, - INTRINSIC_ASSIGN, + INTRINSIC_ASSIGN, INTRINSIC_PARENTHESES, GFC_INTRINSIC_END /* Sentinel */ } gfc_intrinsic_op; Index: expr.c =================================================================== --- expr.c (revision 110794) +++ expr.c (working copy) @@ -782,6 +782,7 @@ simplify_intrinsic_op (gfc_expr * p, int switch (p->value.op.operator) { case INTRINSIC_UPLUS: + case INTRINSIC_PARENTHESES: result = gfc_uplus (op1); break; Index: module.c =================================================================== --- module.c (revision 110794) +++ module.c (working copy) @@ -2455,6 +2455,7 @@ static const mstring intrinsics[] = minit ("LT", INTRINSIC_LT), minit ("LE", INTRINSIC_LE), minit ("NOT", INTRINSIC_NOT), + minit ("PARENTHESES", INTRINSIC_PARENTHESES), minit (NULL, -1) }; Index: resolve.c =================================================================== --- resolve.c (revision 110794) +++ resolve.c (working copy) @@ -1692,6 +1692,7 @@ resolve_operator (gfc_expr * e) case INTRINSIC_NOT: case INTRINSIC_UPLUS: case INTRINSIC_UMINUS: + case INTRINSIC_PARENTHESES: if (gfc_resolve_expr (e->value.op.op1) == FAILURE) return FAILURE; break; @@ -1835,6 +1836,9 @@ resolve_operator (gfc_expr * e) goto bad_op; + case INTRINSIC_PARENTHESES: + break; + default: gfc_internal_error ("resolve_operator(): Bad intrinsic"); } @@ -1911,6 +1915,7 @@ resolve_operator (gfc_expr * e) case INTRINSIC_NOT: case INTRINSIC_UPLUS: case INTRINSIC_UMINUS: + case INTRINSIC_PARENTHESES: e->rank = op1->rank; if (e->shape == NULL) Index: match.c =================================================================== --- match.c (revision 110794) +++ match.c (working copy) @@ -58,6 +58,7 @@ mstring intrinsic_operators[] = { minit (".gt.", INTRINSIC_GT), minit (">", INTRINSIC_GT), minit (".not.", INTRINSIC_NOT), + minit ("parens", INTRINSIC_PARENTHESES), minit (NULL, INTRINSIC_NONE) };