133 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Regression test for more than one part-ref with nonzero rank3 4program m5 interface6 function real_info1(i)7 end8 subroutine real_info2()9 end10 subroutine real_generic()11 end12 end interface13 type mt14 complex :: c, c2(2)15 integer :: x, x2(2)16 character(10) :: s, s2(2)17 real, pointer :: p18 real, allocatable :: a19 contains20 procedure, nopass :: info1 => real_info121 procedure, nopass :: info2 => real_info222 procedure, nopass :: real_generic23 generic :: g1 => real_generic24 end type25 type mt226 type(mt) :: t1(2,2)27 end type28 type mt329 type(mt2) :: t2(2)30 end type31 type mt432 type(mt3) :: t3(2)33 end type34 type(mt4) :: t(2)35 36 print *, t(1)%t3(1)%t2(1)%t1%x ! no error37 print *, t(1)%t3(1)%t2(1)%t1%x2(1) ! no error38 print *, t(1)%t3(1)%t2(1)%t1%s(1:2) ! no error39 print *, t(1)%t3(1)%t2(1)%t1%s2(1)(1:2) ! no error40 print *, t(1)%t3(1)%t2(1)%t1%c%RE ! no error41 print *, t(1)%t3(1)%t2(1)%t1%c%IM ! no error42 print *, t(1)%t3(1)%t2(1)%t1%c2(1)%RE ! no error43 print *, t(1)%t3(1)%t2(1)%t1%c2(1)%IM ! no error44 45 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed46 print *, t%t3%t2%t1%x47 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed48 print *, t(1)%t3%t2%t1%x49 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed50 print *, t(1)%t3(1)%t2%t1%x51 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed52 print *, t(1)%t3%t2(1)%t1%x53 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed54 print *, t%t3%t2%t1%x2(1)55 !ERROR: Reference to whole rank-1 component 'x2' of rank-2 array of derived type is not allowed56 print *, t(1)%t3%t2%t1%x257 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed58 print *, t(1)%t3(1)%t2%t1%x2(1)59 !ERROR: Subscripts of component 'x2' of rank-2 derived type array have rank 1 but must all be scalar60 print *, t(1)%t3(1)%t2(1)%t1%x2(1:)61 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed62 print *, t%t3%t2%t1%s(1:2)63 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed64 print *, t(1)%t3%t2(1)%t1%s(1:2)65 !ERROR: Subscripts of component 't1' of rank-1 derived type array have rank 1 but must all be scalar66 print *, t%t3%t2%t1(1,:)%s(1:2)67 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed68 print *, t%t3%t2%t1%s2(1)(1:2)69 !ERROR: Subscripts of component 's2' of rank-2 derived type array have rank 1 but must all be scalar70 print *, t(1)%t3%t2%t1%s2(1:)(1:2)71 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed72 print *, t%t3%t2%t1%c%RE73 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed74 print *, t(1)%t3%t2%t1%c%RE75 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed76 print *, t(1)%t3(1)%t2%t1%c%RE77 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed78 print *, t(1)%t3%t2(1)%t1%c%RE79 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed80 print *, t%t3%t2%t1%c%IM81 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed82 print *, t%t3%t2%t1%c2(1)%RE83 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed84 print *, t(1)%t3%t2%t1%c2(1)%RE85 !ERROR: Subscripts of component 'c2' of rank-2 derived type array have rank 1 but must all be scalar86 print *, t(1)%t3(1)%t2%t1%c2(1:)%RE87 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed88 print *, t(1)%t3%t2(1)%t1%c2(1)%RE89 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed90 print *, t%t3%t2%t1%c2(1)%IM91 92 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed93 call sub0(t%t3%t2%t1%info1(i))94 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed95 call sub0(t%t3%t2%t1%info1)96 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed97 call t%t3%t2%t1%info298 !ERROR: Reference to whole rank-2 component 't1' of rank-1 array of derived type is not allowed99 call t%t3%t2%t1%g1100 101 !ERROR: Reference to rank-2 object 't1' has 1 subscripts102 call sub0(t%t3%t2%t1(1)%info1(i))103 !ERROR: Reference to rank-2 object 't1' has 1 subscripts104 call sub0(t%t3%t2%t1(1)%info1)105 !ERROR: Reference to rank-2 object 't1' has 1 subscripts106 call t%t3%t2%t1(1)%info2107 !ERROR: Reference to rank-2 object 't1' has 1 subscripts108 call t%t3%t2%t1(1)%g1109 110 !ERROR: Reference to rank-2 object 't1' has 1 subscripts111 call sub0(t%t3%t2%t1(1:)%info1(i))112 !ERROR: Reference to rank-2 object 't1' has 1 subscripts113 call sub0(t%t3%t2%t1(1:)%info1)114 !ERROR: Reference to rank-2 object 't1' has 1 subscripts115 call t%t3%t2%t1(1:)%info2116 !ERROR: Reference to rank-2 object 't1' has 1 subscripts117 call t%t3%t2%t1(1:)%g1118 119 !ERROR: An allocatable or pointer component reference must be applied to a scalar base120 print *, t(1)%t3(1)%t2(1)%t1%p121 !ERROR: An allocatable or pointer component reference must be applied to a scalar base122 print *, t%t3(1)%t2(1)%t1(1,1)%p123 !ERROR: An allocatable or pointer component reference must be applied to a scalar base124 print *, t(1)%t3(1)%t2(1)%t1%a125 !ERROR: An allocatable or pointer component reference must be applied to a scalar base126 print *, t%t3(1)%t2(1)%t1(1,1)%a127 !ERROR: An allocatable or pointer component reference must be applied to a scalar base128 t(1)%t3(1)%t2(1)%t1%p => null()129 !ERROR: An allocatable or pointer component reference must be applied to a scalar base130 t%t3(1)%t2(1)%t1(1,1)%p => null()131 132end133