Bug 37297 - [OOP] Ambiguity check for GENERIC bindings is not yet fully conformant
Summary: [OOP] Ambiguity check for GENERIC bindings is not yet fully conformant
Status: RESOLVED DUPLICATE of bug 47710
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2008-08-31 10:18 UTC by Daniel Kraft
Modified: 2011-09-10 08:45 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-03-29 08:54:02


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Kraft 2008-08-31 10:18:46 UTC
In the current implementation of GENERIC type-bound procedures the check if two specific targets of a GENERIC binding could be ambiguous (see standard 16.2.3 Restrictions on generic declarations) is not conformant with this section as it does not handle passed-objects at the moment.  The following code is accepted:

MODULE m

  TYPE t
  CONTAINS
    PROCEDURE, PASS :: proc1
    PROCEDURE, NOPASS :: proc2
    GENERIC :: gen => proc1, proc2
  END TYPE t

CONTAINS

  SUBROUTINE proc1 (me)
    IMPLICIT NONE
    TYPE(t) :: me
  END SUBROUTINE proc1

  SUBROUTINE proc2 ()
    IMPLICIT NONE
  END SUBROUTINE proc2

END MODULE m

PROGRAM main
  USE m
  IMPLICIT NONE

  TYPE(t) :: myobj

  CALL myobj%gen ()
END PROGRAM main

While the CALL in the main-program would fit to both specific targets.
Comment 1 janus 2011-09-10 08:45:00 UTC
Note: The test case in comment #0 is (correctly) rejected with

    PROCEDURE, PASS :: proc1
             1
Error: Non-polymorphic passed-object dummy argument of 'proc1' at (1)



However, when correcting this, it is still accepted:

MODULE m

  IMPLICIT NONE

  TYPE t
  CONTAINS
    PROCEDURE, PASS :: proc1
    PROCEDURE, NOPASS :: proc2
    GENERIC :: gen => proc1, proc2
  END TYPE

CONTAINS

  SUBROUTINE proc1 (me)
    CLASS(t) :: me
  END SUBROUTINE

  SUBROUTINE proc2 ()
  END SUBROUTINE

END MODULE

PROGRAM main
  USE m
  IMPLICIT NONE
  TYPE(t) :: myobj
  CALL myobj%gen ()
END PROGRAM main
 


This is the same issue as the one reported in PR47710.

*** This bug has been marked as a duplicate of bug 47710 ***