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]

[gfortran, patch] PR17711: distinguish between .EQ. and == etc.



This is a rather straightforward solution to the problem of printing the right operator name for intrinsic comparison operators, when an error is issued. The goal is achieved by keeping track of which operator the user used in the first place, they are distinguished by using INTRINSIC_EQ2 for ".EQ." versus INTRINSIC_EQ for "==" etc.


While I was at it I also fixed a few inconsistent error messages which made necessary a change to gfortran.dg/logical_comp.f90.

Built and tested on i686/darwin. Ok for trunk?

:ADDPATCH fortran:

        * gfortran.h (gfc_intrinsic_op): Add INTRINSIC_EQ2, INTRINSIC_NE2,
        INTRINSIC_GT2, INTRINSIC_GE2, INTRINSIC_LT2, INTRINSIC_LE2.
        * arith.c (eval_intrinsic, eval_intrinsic0): Likewise.
        (gfc_eq2, gfc_ne2, gfc_gt2, gfc_ge2, gfc_lt2, gfc_le2): New
        functions, dealing with new enum values.
        * arith.h: Add prototypes for new functions.
        * dump-parse-tree.c (gfc_show_expr): Account for new enum
        values.
        * expr.c (simplify_intrinsic_op, check_intrinsic_op): Likewise.
        * interface.c (check_operator_interface): Likewise.
        * match.c (intrinsic_operators): Distinguish FORTRAN 77 style
        operators from Fortran 90 style operators using new enum values.
        * matchexp.c (match_level_4):  Account for new enum values.
        * module.c (mio_expr): Likewise.
        * resolve.c (resolve_operator): Deal with new enum values, fix
        inconsistent error messages.
        * trans-expr.c (gfc_conv_expr_op):  Account for new enum
        values.

Diff for the old testcase:
Index: logical_comp.f90
===================================================================
--- logical_comp.f90    (revision 119090)
+++ logical_comp.f90    (working copy)
@@ -4,6 +4,6 @@

 program foo
   logical :: b
-  b = b .eq. b  ! { dg-error ".EQV. instead of .eq." }
-  b = b .ne. b  ! { dg-error ".NEQV. instead of .ne." }
+  b = b .eq. b  ! { dg-error "'.eqv.' instead of '.eq.'" }
+  b = b .ne. b  ! { dg-error "'.neqv.' instead of '.ne.'" }
 end program

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Attachment: 17711.txt
Description: Text document

! PR 17711 : Verify error message text meets operator in source
! { dg-do compile }
LOGICAL A
INTEGER B

A = (A == B)   ! { dg-error "comparison operator '=='" }
A = (A.EQ.B)   ! { dg-error "comparison operator '.eq.'" }
A = (A /= B)   ! { dg-error "comparison operator '/='" }
A = (A.NE.B)   ! { dg-error "comparison operator '.ne.'" }
A = (A <= B)   ! { dg-error "comparison operator '<='" }
A = (A.LE.B)   ! { dg-error "comparison operator '.le.'" }
A = (A <  B)   ! { dg-error "comparison operator '<'" }
A = (A.LT.B)   ! { dg-error "comparison operator '.lt.'" }
A = (A >= B)   ! { dg-error "comparison operator '>='" }
A = (A.GE.B)   ! { dg-error "comparison operator '.ge.'" }
A = (A >  B)   ! { dg-error "comparison operator '>'" }
A = (A.GT.B)   ! { dg-error "comparison operator '.gt.'" }

end

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