public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/41023]  New: Inconsistent error locations for wrong interfaces with overloaded operators
@ 2009-08-10 11:16 domob at gcc dot gnu dot org
  2009-08-10 11:18 ` [Bug fortran/41023] " domob at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: domob at gcc dot gnu dot org @ 2009-08-10 11:16 UTC (permalink / raw)
  To: gcc-bugs

When defining an OPERATOR(...) for intrinsic operators or ASSIGNMENT(=), the
interface of the provided procedure must match certain characteristics (like
one or two dummy arguments, being a FUNCTION/SUBROUTINE, respectively, and so
on).

For a wrong interface, gfortran correctly prints an error message.  The source
location this is associated to is however quite inconsistent and misleading. 
For instance with the example:

MODULE m
  IMPLICIT NONE

  TYPE t
    INTEGER :: num
  END TYPE t

  INTERFACE OPERATOR(+)
    MODULE PROCEDURE myplus
  END INTERFACE OPERATOR(+)

CONTAINS

  INTEGER FUNCTION myplus (a, b, c)
    TYPE(t), INTENT(IN) :: a, b, c
    myplus = a%num + b%num + 42
  END FUNCTION myplus

END MODULE m

I get this error:

[/tmp]# gfortran-dev test.f03 
test.f03:14.25:

  INTEGER FUNCTION myplus (a, b, c)
                         1
Error: Operator interface at (1) has the wrong number of arguments

It is of course right, but I would expect at least a reference to where myplus
is actually defined as OPERATOR(+).  On the other hand, for

MODULE m
  IMPLICIT NONE

  TYPE t
    INTEGER :: num
  END TYPE t

  INTERFACE OPERATOR(+)
    MODULE PROCEDURE myplus
  END INTERFACE OPERATOR(+)

CONTAINS

  SUBROUTINE myplus (a, b)
    TYPE(t), INTENT(IN) :: a, b
  END SUBROUTINE myplus

END MODULE m

I get:

[/tmp]# gfortran-dev test.f03 
test.f03:9.27:

    MODULE PROCEDURE myplus
                           1
Error: Intrinsic operator interface at (1) must be a FUNCTION

Which is quite better, in my opinion.  I suggest we change the error location
in every case to the MODULE PROCEDURE line, which is more reasonable IMHO as
well as consistent.  Alternatively, we could also reference both locations (but
should also do this in both cases to stay consistent).


-- 
           Summary: Inconsistent error locations for wrong interfaces with
                    overloaded operators
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: domob at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41023


^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <bug-41023-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2011-03-13 15:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-10 11:16 [Bug fortran/41023] New: Inconsistent error locations for wrong interfaces with overloaded operators domob at gcc dot gnu dot org
2009-08-10 11:18 ` [Bug fortran/41023] " domob at gcc dot gnu dot org
2009-08-10 20:54 ` dominiq at lps dot ens dot fr
2010-04-18 15:37 ` dominiq at lps dot ens dot fr
2010-04-19 17:58 ` mikael at gcc dot gnu dot org
2010-04-20 14:21 ` mikael at gcc dot gnu dot org
     [not found] <bug-41023-4@http.gcc.gnu.org/bugzilla/>
2011-03-13 15:24 ` pault at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).