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

--- Comment #7 from janus at gcc dot gnu.org 2012-04-25 17:57:11 UTC ---
(In reply to comment #6)
> Here is a maximally reduced test case, which yields the same error as
> iso_c_binding_rename_1.f90 (if the code from comment #2 is removed):

Another variant:


program p
  use iso_c_binding, only: c_ptr, c_associated, &
                           my_cptr_1 => c_ptr, my_cptr_2 => c_ptr
  implicit none
  type(c_ptr) :: my_ptr
  type(my_cptr_1) :: my_ptr_1
  type(my_cptr_2) :: my_ptr_2
  print *, c_associated (my_ptr)    ! passed TYPE(c_ptr) to TYPE(my_cptr_2)
  print *, c_associated (my_ptr_1)  ! passed TYPE(my_cptr_1) to TYPE(my_cptr_2)
  print *, c_associated (my_ptr_2)  ! works
end


The problem is apparently that the type of c_associated's argument is being
renamed to 'my_cptr_2'. I also constructed an analogous test case with a
derived type instead of c_ptr, which works correctly:


module m
  type :: t
  end type
contains
  logical function test(x)
    type(t) :: x
  end function
end module

program p
  use m, only: t, test, t1 => t, t2 => t
  implicit none
  type(t) :: y
  type(t1) :: y1
  type(t2) :: y2
  print *, test (y)   ! works
  print *, test (y1)  ! works
  print *, test (y2)  ! works
end 


This means the problem is special to ISO_C_BINDING.

Reply via email to