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

* [Bug fortran/41023] Inconsistent error locations for wrong interfaces with overloaded operators
  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 ` domob at gcc dot gnu dot org
  2009-08-10 20:54 ` dominiq at lps dot ens dot fr
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: domob at gcc dot gnu dot org @ 2009-08-10 11:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from domob at gcc dot gnu dot org  2009-08-10 11:18 -------
The same holds for type-bound operators, see for instance
gcc/testsuite/gfortran.dg/typebound_operator_2.f03 for the current
"inconsistent" locations.

But as the checking code is mainly shared, a fix will probably do both in one. 
I think though that this should be verified (e.g. by adapting the mentioned
test-case to the new error locations which will be necessary anyways).


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/41023] Inconsistent error locations for wrong interfaces with overloaded operators
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-08-10 20:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dominiq at lps dot ens dot fr  2009-08-10 20:54 -------
I think the ifort messages are more helpful:

[ibook-dhum] f90/bug% ifc pr41023.f90
pr41023.f90(14): error #6711: The number of function arguments is inconsistent
with the intrinsic use of the OPERATOR.   [MYPLUS]
  INTEGER FUNCTION myplus (a, b, c)
-------------------^
compilation aborted for pr41023.f90 (code 1)

[ibook-dhum] f90/bug% ifc pr41023_1.f90
pr41023_1.f90(14): error #6708: A specific procedure must be a function for a
defined OPERATOR.   [MYPLUS]
  SUBROUTINE myplus (a, b)
-------------^
compilation aborted for pr41023_1.f90 (code 1)


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/41023] Inconsistent error locations for wrong interfaces with overloaded operators
  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
  4 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens dot fr @ 2010-04-18 15:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from dominiq at lps dot ens dot fr  2010-04-18 15:37 -------
Confirmed. Note that between 4.4 and 4.5 the error from the second test of
comment #0 has changed from:

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

to

  SUBROUTINE myplus (a, b)
                   1
Error: Intrinsic operator interface at (1) must be a FUNCTION

So the errors for the two tests are now consistent. However I am not sure of
where is the best location for them (probably in both places).


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/41023] Inconsistent error locations for wrong interfaces with overloaded operators
  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
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 7+ messages in thread
From: mikael at gcc dot gnu dot org @ 2010-04-19 17:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from mikael at gcc dot gnu dot org  2010-04-19 17:58 -------
Probably changed in pr40823.


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/41023] Inconsistent error locations for wrong interfaces with overloaded operators
  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
                   ` (3 preceding siblings ...)
  2010-04-19 17:58 ` mikael at gcc dot gnu dot org
@ 2010-04-20 14:21 ` mikael at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: mikael at gcc dot gnu dot org @ 2010-04-20 14:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mikael at gcc dot gnu dot org  2010-04-20 14:21 -------
Created an attachment (id=20444)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20444&action=view)
patch

This produces :

pr41023.f90:9.21:

    MODULE PROCEDURE myplus
                     1
Error: Operator interface at (1) has the wrong number of arguments


and :

pr41023_bis.f90:9.21:

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


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/41023] Inconsistent error locations for wrong interfaces with overloaded operators
       [not found] <bug-41023-4@http.gcc.gnu.org/bugzilla/>
@ 2011-03-13 15:24 ` pault at gcc dot gnu.org
  0 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu.org @ 2011-03-13 15:24 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.03.13 15:24:42
                 CC|                            |pault at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> 2011-03-13 15:24:42 UTC ---
This can be confirmed

Paul


^ permalink raw reply	[flat|nested] 7+ messages in thread

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).