73 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic2!3! Error tests for structure constructors of derived types with allocatable components4 5module m6 type parent17 integer, allocatable :: pa8 end type parent19 type parent210 real, allocatable :: pa(:)11 end type parent212 type child13 integer :: i14 type(parent2) :: ca15 end type16 17contains18 subroutine test1()19 integer :: j20 real :: arr(5)21 integer, pointer :: ipp22 real, pointer :: rpp(:)23!ERROR: Must be a constant value24 type(parent1) :: tp1 = parent1(3)25!ERROR: Must be a constant value26 type(parent1) :: tp2 = parent1(j)27 type(parent1) :: tp3 = parent1(null())28!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wnull-mold-allocatable-component-value]29 type(parent1) :: tp4 = parent1(null(ipp))30 31!ERROR: Must be a constant value32 type(parent2) :: tp5 = parent2([1.1,2.1,3.1])33!ERROR: Must be a constant value34 type(parent2) :: tp6 = parent2(arr)35 type(parent2) :: tp7 = parent2(null())36!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wnull-mold-allocatable-component-value]37 type(parent2) :: tp8 = parent2(null(rpp))38 end subroutine test139 40 subroutine test2()41 integer :: j42 real :: arr(5)43 integer, pointer :: ipp44 real, pointer :: rpp(:)45 type(parent1) :: tp146 type(parent2) :: tp247 tp1 = parent1(3)48 tp1 = parent1(j)49 tp1 = parent1(null())50!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wnull-mold-allocatable-component-value]51 tp1 = parent1(null(ipp))52 53 tp2 = parent2([1.1,2.1,3.1])54 tp2 = parent2(arr)55 tp2 = parent2(null())56!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wnull-mold-allocatable-component-value]57 tp2 = parent2(null(rpp))58 end subroutine test259 60 subroutine test3()61 real, pointer :: pp(:)62 type(child) :: tc1 = child(5, parent2(null()))63!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wnull-mold-allocatable-component-value]64 type(child) :: tc10 = child(5, parent2(null(pp)))65!ERROR: Must be a constant value66 type(child) :: tc3 = child(5, parent2([1.1,1.2]))67 type(child) :: tc468 69 tc4 = child(5, parent2(null()))70 tc4 = child(5, parent2([1.1,1.2]))71 end subroutine test372end module m73