This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

[gfortran] Fix PR15963



PR 15963 was a case where we were restricted expressions had become overly restricted: we didn't allow character comparisons. Appended patch fixes this. A suggestion for a better error message is welcome, my wording makes it seem as if 'a'<2 was allowed. Along the way, I made the logic for INTRINSIC_POWER in that same case a little easier.


Built and tested on i686-pc-linux. I will also add a testcase to the testsuite.

- Tobi

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.	
	

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      22 Jun 2004 14:30:46 -0000
@@ -1167,6 +1167,18 @@ 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 +1191,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]