Update ChangeLog and version files for release
[official-gcc.git] / gcc / testsuite / gfortran.dg / select_type_17.f03
blobaf2a489d9714fda6274ad84e750ef40afe3f87f5
1 ! { dg-do compile }
2 ! { dg-options "-std=f2003" }
4 ! PR fortran/44044
5 ! Definability check for select type to expression.
6 ! This is "bonus feature #2" from comment #3 of the PR.
8 ! Contributed by Janus Weil, janus@gcc.gnu.org.
10 implicit none
12 type :: t1
13   integer :: i
14 end type
16 type, extends(t1) :: t2
17 end type
19 type(t1),target :: x1
20 type(t2),target :: x2
22 select type ( y => fun(1) )
23 type is (t1)
24   y%i = 1 ! { dg-error "variable definition context" }
25 type is (t2)
26   y%i = 2 ! { dg-error "variable definition context" }
27 end select
29 contains
31   function fun(i)
32     class(t1),pointer :: fun
33     integer :: i
34     if (i>0) then
35       fun => x1
36     else if (i<0) then
37       fun => x2
38     else
39       fun => NULL()
40     end if
41   end function
43 end