1! { dg-do run }
2! { dg-options "-finit-real=NAN" }
3! { dg-add-options ieee }
4! { dg-skip-if "NaN not supported" { spu-*-* } }
5!
6! PR fortran/50619
7!
8! Contributed by Fred Krogh
9!
10! The NaN initialization used to set the associate name to NaN!
11!
12
13module testa2
14type, public ::  test_ty
15  real :: rmult = 1.0e0
16end type test_ty
17
18contains
19  subroutine test(e, var1)
20    type(test_ty) :: e
21    real :: var1, var2 ! Should get NaN initialized
22
23    ! Should be the default value
24    if (e%rmult /= 1.0) STOP 1
25
26    ! Check that NaN initialization is really turned on
27    if (var1 == var1) STOP 2
28    if (var2 == var2) STOP 3
29
30    ! The following was failing:
31    associate (rmult=>e%rmult)
32      if (e%rmult /= 1.0) STOP 4
33    end associate
34  end subroutine test
35end module testa2
36
37program testa1
38  use testa2
39  type(test_ty) :: e
40  real :: var1 ! Should get NaN initialized
41  call test(e, var1)
42  stop
43end program testa1
44