view gcc/testsuite/gfortran.dg/submodule_25.f08 @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900 (2018-10-24)
parents 04ced10e8804
children
line wrap: on
line source
! { dg-do compile }
! Test the fix for PR79434 in which the PRIVATE attribute of the
! component 'i' of the derived type 't' was not respected in the
! submodule 's_u'.
!
! Contributed by Reinhold Bader  <Bader@lrz.de>
!
module mod_encap_t
  implicit none
  type, public :: t
    private
    integer :: i
  end type
end module
module mod_encap_u
  use mod_encap_t
  type, public, extends(t) :: u
    private
    integer :: j
  end type
  interface
    module subroutine fu(this)
      type(u), intent(inout) :: this
    end subroutine
  end interface
end module
submodule (mod_encap_u) s_u
contains
  module procedure fu
!   the following statement should cause the compiler to
!   abort, pointing out a private component defined in
!   a USED module is being accessed
    this%i = 2 ! { dg-error "is a PRIVATE component" }
    this%j = 1
    write(*, *) 'FAIL'
  end procedure
end submodule
program p
  use mod_encap_u
  implicit none
  type(u) :: x
  call fu(x)
end program