modula2: Simplify REAL/LONGREAL/SHORTREAL node creation.
[official-gcc.git] / gcc / testsuite / gfortran.dg / pr110224.f90
blob186bbf5fe273bf80f6de55c1226df92fbd4e3293
1 ! { dg-do compile }
3 ! Contributed by Neil Carlson <neil.n.carlson@gmail.com>
5 module mod
6 type :: foo
7 real, pointer :: var
8 contains
9 procedure :: var_ptr
10 end type
11 contains
12 function var_ptr(this) result(ref)
13 class(foo) :: this
14 real, pointer :: ref
15 ref => this%var
16 end function
17 end module
18 program main
19 use mod
20 type(foo) :: x
21 allocate (x%var, source = 2.0)
22 associate (var => x%var_ptr())
23 var = 1.0
24 end associate
25 if (x%var .ne. 1.0) stop 1
26 x%var_ptr() = 2.0
27 if (x%var .ne. 2.0) stop 2
28 deallocate (x%var)
29 end program