This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] Fix PR15963


Paul Brook wrote:
>>2004-06-22  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
>>
>>	PR fortran/15963
>>	* expr.c (check_intrinsic_op): Allow comparison of characters.
>>	Make logic easier.
> 
> 
> Capitalise CHARACTER in the error message.
> Otherwise, Ok.

I committed this in the form shown below. I slightly revised the check,
to put it in a more readable form, as I had messed up when applying my
patch to a clean tree, and after it had taken me a while to untangle the
logical expression, to see where the bug was, I decided to make up a
clearer one.

- Tobi

Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/expr.c,v
retrieving revision 1.7
diff -u -p -r1.7 expr.c
--- expr.c      27 May 2004 12:35:11 -0000      1.7
+++ expr.c      29 Jun 2004 16:59:48 -0000
@@ -1167,6 +1167,17 @@ check_intrinsic_op (gfc_expr * e, try (*
     case INTRINSIC_GE:
     case INTRINSIC_LT:
     case INTRINSIC_LE:
+      if ((*check_function) (e->op2) == FAILURE)
+       return FAILURE;
+
+      if (!(et0 (e->op1) == BT_CHARACTER && et0 (e->op2) == BT_CHARACTER)
+         && !(numeric_type (et0 (e->op1)) && numeric_type (et0 (e->op2))))
+       {
+         gfc_error ("Numeric or CHARACTER operands are required in "
+                    "expression at %L", &e->where);
+         return FAILURE;
+       }
+      break;

     case INTRINSIC_PLUS:
     case INTRINSIC_MINUS:
@@ -1179,10 +1190,8 @@ check_intrinsic_op (gfc_expr * e, try (*
       if (!numeric_type (et0 (e->op1)) || !numeric_type (et0 (e->op2)))
        goto not_numeric;

-      if (e->operator != INTRINSIC_POWER)
-       break;
-
-      if (check_function == check_init_expr && et0 (e->op2) != BT_INTEGER)
+      if (e->operator == INTRINSIC_POWER
+         && check_function == check_init_expr && et0 (e->op2) !=
BT_INTEGER)
        {
          gfc_error ("Exponent at %L must be INTEGER for an initialization "
                     "expression", &e->op2->where);




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]