aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/contained_3.f90
blob: d5543a149f01479a9b206db08a2292a9680c27ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
! { dg-do run }
! Tests the fix for PR33897, in which gfortran missed that the
! declaration of 'setbd' in 'nxtstg2' made it external.  Also
! the ENTRY 'setbd' would conflict with the external 'setbd'.
!
! Contributed by Michael Richmond <michael.a.richmond@nasa.gov>
!
MODULE ksbin1_aux_mod
 CONTAINS
  SUBROUTINE nxtstg1()
    INTEGER :: i
    i = setbd()  ! available by host association.
    if (setbd () .ne. 99 ) call abort ()
  END SUBROUTINE nxtstg1

  SUBROUTINE nxtstg2()
    INTEGER :: i
    integer :: setbd  ! makes it external.
    i = setbd()       ! this is the PR
    if (setbd () .ne. 42 ) call abort ()
  END SUBROUTINE nxtstg2

  FUNCTION binden()
    INTEGER :: binden
    INTEGER :: setbd
    binden = 0
  ENTRY setbd()
    setbd = 99
  END FUNCTION binden
END MODULE ksbin1_aux_mod

PROGRAM test
  USE ksbin1_aux_mod, only : nxtstg1, nxtstg2
  integer setbd ! setbd is external, since not use assoc.
  CALL nxtstg1()
  CALL nxtstg2()
  if (setbd () .ne. 42 ) call abort ()
  call foo
contains
  subroutine foo
    USE ksbin1_aux_mod ! module setbd is available
    if (setbd () .ne. 99 ) call abort ()
  end subroutine
END PROGRAM test

INTEGER FUNCTION setbd()
  setbd=42
END FUNCTION setbd