Hi Paul,

On 02.02.21 13:20, Paul Richard Thomas via Gcc-patches wrote:
This is more or less 'obvious' and does not require any further explanation.

Well, I am not sure whether calling resolve is premature or not. In any
case, it still fails for the attached testcase. (Related but separate
issue.)

The second testcase fails with "Selector at (1) has no type" / "Symbol
'var' at (1) has no IMPLICIT type".

Disclaimer: I am not 100% sure whether those two or your/the PR's
testcase is valid. (It fails to compile with ifort 19.1. I have not read
the spec and assume that the original testcase is valid.)

Thus, please confirm that all three are valid. If so, do you see a way
to make the two new ones pass as well? If we are sure that the current
patch is still the right approach, I am also fine to do it stepwise.

Thanks,

Tobias

Regtests with FC33/x86_64 - OK for master (and ....)?

Paul

Fortran: Fix calls to associate name typebound subroutines [PR98897].

2021-02-02  Paul Thomas  <pa...@gcc.gnu.org>

gcc/fortran
PR fortran/98897
* match.c (gfc_match_call): Include associate names as possible
entities with typebound subroutines. The target needs to be
resolved for the type.

gcc/testsuite/
PR fortran/98897
* gfortran.dg/typebound_call_32.f90: New test.
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München 
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank 
Thürauf
module m
  implicit none
contains
  subroutine double(i)
    integer :: i
    i = 2*i
  end subroutine double

  function bar() result(res)
    procedure(double), pointer :: res
    res => double
  end function bar
  subroutine foo(i)
    integer :: i

    ! This works:
    procedure(), pointer :: proc
    call double(i)
    proc => bar()
    call proc(i)

    ! This fails:
    associate (var => bar())
      call var(i)  ! { dg-bogus "VARIABLE attribute of 'var' conflicts with PROCEDURE attribute" }
    end associate
  end subroutine foo

end module m

program test
  use m
  implicit none (type, external)
  integer :: i
  i = 50
  call foo(i)
  if (i /= 50*2*2) stop 1
end program test
module m
  implicit none
contains
  subroutine double(i)
    integer :: i
    i = 2*i
  end subroutine double

  function bar() result(res)
    procedure(double), pointer :: res
    res => double
  end function bar

  subroutine foo(i)
    integer :: i
    procedure(bar) :: var

    procedure(double), pointer :: proc
    associate (var => bar())
      proc => var
    end associate
    call proc(i)
  end subroutine foo

end module m

program test
  use m
  implicit none (type, external)
  integer :: i
  i = 50
  call foo(i)
  if (i /= 50*2) stop 1
end program test

Reply via email to