This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran] PR31580 - improved error message if operator-not-found
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 29 Jun 2007 20:47:48 +0200
- Subject: [patch, fortran] PR31580 - improved error message if operator-not-found
This code
implicit none
real :: a,b
if(a .nonex. b) stop
end
is currently flagged as:
Error: Operands of user operator 'nonex' at (1) are REAL(4)/REAL(4)
A more descriptive error message is preferable.
Attached simple patch speaks for itself.
:ADDPATCH fortran:
gcc/fortran:
2007-06-29 Daniel Franke <franke.daniel@gmail.com>
PR fortran/31580
* resolve.c (resolve_operator): Added check whether a user defined
operator is available.
gcc/testsuite:
2007-06-29 Daniel Franke <franke.daniel@gmail.com>
PR fortran/31580
* gfortran.dg/operator_3.f90: New test.
Regtested on i686-pc-linux-gnu. Ok for trunk?
Regards
Daniel
Index: fortran/resolve.c
===================================================================
--- fortran/resolve.c (revision 126079)
+++ fortran/resolve.c (working copy)
@@ -2251,7 +2257,9 @@
goto bad_op;
case INTRINSIC_USER:
- if (op2 == NULL)
+ if (e->value.op.uop->operator == NULL)
+ sprintf (msg, _("Unknown operator '%s' at %%L"), e->value.op.uop->name);
+ else if (op2 == NULL)
sprintf (msg, _("Operand of user operator '%s' at %%L is %s"),
e->value.op.uop->name, gfc_typename (&op1->ts));
else
Index: testsuite/gfortran.dg/operator_3.f90
===================================================================
--- testsuite/gfortran.dg/operator_3.f90 (revision 0)
+++ testsuite/gfortran.dg/operator_3.f90 (revision 0)
@@ -0,0 +1,9 @@
+! { dg-compile }
+! PR fortran/31580
+!
+! Testcase contributed by Tobias Burnus <burnus AT gcc DOT gnu DOT org>
+!
+PROGRAM test
+ real :: a,b
+ if(a .nonex. b) stop ! { dg-error "Unknown operator" }
+end program