summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/used_dummy_types_8.f90
blob: 8a966a80a533f79c5515102cda87dabd8e2781e6 (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
! { dg-do compile }
! Tests the fix for PR30880, in which the variable d1
! in module m1 would cause an error in the main program
! because it has an initializer and is a dummy.  This
! came about because the function with multiple entries
! assigns the initializer earlier than for other cases.
!
! Contributed by Joost VandeVondele <jv244@cam.ac.uk> 
!
MODULE M1
  TYPE T1
  INTEGER :: i=7
  END TYPE T1
CONTAINS
  FUNCTION F1(d1) RESULT(res)
    INTEGER :: res
    TYPE(T1), INTENT(OUT) :: d1
    TYPE(T1), INTENT(INOUT) :: d2
    res=d1%i
    d1%i=0
    RETURN
  ENTRY E1(d2) RESULT(res)
    res=d2%i
    d2%i=0
  END FUNCTION F1
END MODULE M1

  USE M1
  TYPE(T1) :: D1
  D1=T1(3)
  write(6,*) F1(D1)
  D1=T1(3)
  write(6,*) E1(D1)
END
! { dg-final { cleanup-modules "m1" } }