OSDN Git Service

PR fortran/50409
[pf3gnuchains/gcc-fork.git] / gcc / fortran / matchexp.c
index 0092f40..cd70dc0 100644 (file)
@@ -1,5 +1,5 @@
 /* Expression parser.
-   Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008
+   Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Andy Vaught
 
@@ -130,14 +130,10 @@ gfc_get_parentheses (gfc_expr *e)
 {
   gfc_expr *e2;
 
-  e2 = gfc_get_expr();
-  e2->expr_type = EXPR_OP;
+  e2 = gfc_get_operator_expr (&e->where, INTRINSIC_PARENTHESES, e, NULL);
   e2->ts = e->ts;
   e2->rank = e->rank;
-  e2->where = e->where;
-  e2->value.op.op = INTRINSIC_PARENTHESES;
-  e2->value.op.op1 = e;
-  e2->value.op.op2 = NULL;
+
   return e2;
 }
 
@@ -149,7 +145,6 @@ match_primary (gfc_expr **result)
 {
   match m;
   gfc_expr *e;
-  locus where;
 
   m = gfc_match_literal_constant (result, 0);
   if (m != MATCH_NO)
@@ -164,8 +159,6 @@ match_primary (gfc_expr **result)
     return m;
 
   /* Match an expression in parentheses.  */
-  where = gfc_current_locus;
-
   if (gfc_match_char ('(') != MATCH_YES)
     return MATCH_NO;
 
@@ -198,26 +191,6 @@ syntax:
 }
 
 
-/* Build an operator expression node.  */
-
-static gfc_expr *
-build_node (gfc_intrinsic_op op, locus *where,
-           gfc_expr *op1, gfc_expr *op2)
-{
-  gfc_expr *new_expr;
-
-  new_expr = gfc_get_expr ();
-  new_expr->expr_type = EXPR_OP;
-  new_expr->value.op.op = op;
-  new_expr->where = *where;
-
-  new_expr->value.op.op1 = op1;
-  new_expr->value.op.op2 = op2;
-
-  return new_expr;
-}
-
-
 /* Match a level 1 expression.  */
 
 static match
@@ -228,6 +201,7 @@ match_level_1 (gfc_expr **result)
   locus where;
   match m;
 
+  gfc_gobble_whitespace ();
   where = gfc_current_locus;
   uop = NULL;
   m = match_defined_operator (&uop);
@@ -242,7 +216,7 @@ match_level_1 (gfc_expr **result)
     *result = e;
   else
     {
-      f = build_node (INTRINSIC_USER, &where, e, NULL);
+      f = gfc_get_operator_expr (&where, INTRINSIC_USER, e, NULL);
       f->value.op.uop = uop;
       *result = f;
     }
@@ -254,7 +228,7 @@ match_level_1 (gfc_expr **result)
 /* As a GNU extension we support an expanded level-2 expression syntax.
    Via this extension we support (arbitrary) nesting of unary plus and
    minus operations following unary and binary operators, such as **.
-   The grammar of section 7.1.1.3 is effectively rewitten as:
+   The grammar of section 7.1.1.3 is effectively rewritten as:
 
        R704  mult-operand     is level-1-expr [ power-op ext-mult-operand ]
        R704' ext-mult-operand is add-op ext-mult-operand
@@ -918,7 +892,7 @@ gfc_match_expr (gfc_expr **result)
          return MATCH_ERROR;
        }
 
-      all = build_node (INTRINSIC_USER, &where, all, e);
+      all = gfc_get_operator_expr (&where, INTRINSIC_USER, all, e);
       all->value.op.uop = uop;
     }