view gcc/testsuite/gfortran.dg/used_types_20.f90 @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 04ced10e8804
children
line wrap: on
line source

! { dg-do compile }
! Tests the fix for PR36366 a regression in which the order of USE statements
! in 'test2' would cause the result of 'test1' not to have a reference to
! the derived type 'inner'.
!
! Contributed by Jakub Jelinek <jakub@gcc.gnu.org>
!
MODULE types
  IMPLICIT NONE
  TYPE :: inner
    INTEGER, POINTER :: i(:)
  END TYPE inner

  TYPE :: outer
    TYPE(inner), POINTER :: inr(:)
  END TYPE outer
END MODULE types

MODULE mymod
  IMPLICIT NONE
CONTAINS
  FUNCTION test1()
    USE types
    IMPLICIT NONE
    TYPE(outer), POINTER :: test1
    NULLIFY(test1)
  END FUNCTION test1
END MODULE mymod

MODULE test
  IMPLICIT NONE
CONTAINS

  SUBROUTINE test2(a)
    USE mymod
    USE types
    IMPLICIT NONE
    TYPE(outer), INTENT(INOUT) :: a
    INTEGER :: i
    i = a%inr(1)%i(1)
  END SUBROUTINE test2

  SUBROUTINE test3(a)
    USE types
    IMPLICIT NONE
    TYPE(outer), INTENT(IN) :: a
  END SUBROUTINE test3
END MODULE test