aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/matchexp.c
diff options
context:
space:
mode:
authorTobias Schlüter <tobi@gcc.gnu.org>2006-02-10 01:10:47 +0100
committerTobias Schlüter <tobi@gcc.gnu.org>2006-02-10 01:10:47 +0100
commit2414e1d655249938cc53becd63d8fb95db65bbfe (patch)
treea5d5c040eb2490c1c8811341728f943405f6d7df /gcc/fortran/matchexp.c
parenta286e145de1b08b1a73d4efe03d36375fa698273 (diff)
downloadgcc-2414e1d655249938cc53becd63d8fb95db65bbfe.zip
gcc-2414e1d655249938cc53becd63d8fb95db65bbfe.tar.gz
gcc-2414e1d655249938cc53becd63d8fb95db65bbfe.tar.bz2
re PR fortran/14771 (frontend doesn't record parentheses)
fortran/ 2006-02-09 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> PR fortran/14771 * gfortran.h (gfc_intrinsic_op): Add INTRINSIC_PARENTHESES. * dump-parse-tree (gfc_show_expr): Handle INTRINSIC_PARENTHESES. * expr.c (simplify_intrinsic_op): Treat INTRINSIC_PARENTHESES as if it were INTRINSIC_UPLUS. * resolve.c (resolve_operator): Handle INTRINSIC_PARENTHESES. * match.c (intrinsic_operators): Add INTRINSIC_PARENTHESES. * matchexp.c (match_primary): Record parentheses surrounding numeric expressions. * module.c (intrinsics): Add INTRINSIC_PARENTHESES for module dumping. * trans-expr.c (gfc_conv_expr_op): Handle INTRINSIC_PARENTHESES. testsuite/ 2006-02-09 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> Paul Thomas <pault@gcc.gnu.org> PR fortran/14771 * gfortran.dg/parens_1.f90: New. * gfortran.dg/parens_2.f90: New. * gfortran.dg/parens_3.f90: New. From-SVN: r110819
Diffstat (limited to 'gcc/fortran/matchexp.c')
-rw-r--r--gcc/fortran/matchexp.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/gcc/fortran/matchexp.c b/gcc/fortran/matchexp.c
index a306c95..e4bf44e 100644
--- a/gcc/fortran/matchexp.c
+++ b/gcc/fortran/matchexp.c
@@ -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);