brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · a10a725 Raw
125 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Check for semantic errors in ALLOCATE statements3 4! Creating a symbol that allocate should accept5module share6  real, pointer :: rp7end module share8 9module m10! Creating symbols that allocate should not accept11  type :: a_type12    real, allocatable :: x13    contains14      procedure, pass :: foo => mfoo15      procedure, pass :: bar => mbar16  end type17 18contains19  function mfoo(x)20    class(a_type) :: x21    class(a_type), allocatable :: foo22    foo = x23  end function24  subroutine mbar(x)25    class(a_type) :: x26  end subroutine27end module28 29subroutine C932(ed1, ed5, ed7, edc9, edc10, okad1, okpd1, okacd5)30! Each allocate-object shall be a data pointer or an allocatable variable.31  use :: share32  use :: m, only: a_type33  type TestType134    integer, allocatable :: ok(:)35    integer :: nok(10)36  end type37  type TestType238    integer, pointer :: ok39    integer :: nok40  end type41  interface42    function foo(x)43      real(4) :: foo, x44    end function45    subroutine bar()46    end subroutine47  end interface48  real ed1(:), e249  real, save :: e3[*]50  real , target :: e4, ed5(:)51  real , parameter :: e6 = 5.52  procedure(foo), pointer :: proc_ptr1 => NULL()53  procedure(bar), pointer :: proc_ptr254  type(TestType1) ed755  type(TestType2) e856  type(TestType1) edc9[*]57  type(TestType2) edc10[*]58  class(a_type), allocatable :: a_var59 60  real, allocatable :: oka1(:, :), okad1(:, :), oka261  real, pointer :: okp1(:, :), okpd1(:, :), okp262  real, pointer, save :: okp363  real, allocatable, save :: oka3, okac4[:,:]64  real, allocatable :: okacd5(:, :)[:]65  character(:), allocatable :: chvar66 67  !ERROR: Name in ALLOCATE statement must be a variable name68  allocate(foo)69  !ERROR: Name in ALLOCATE statement must be a variable name70  allocate(bar)71  !ERROR: Name in ALLOCATE statement must be a variable name72  allocate(C932)73  !ERROR: Name in ALLOCATE statement must be a variable name74  allocate(proc_ptr1)75  !ERROR: Name in ALLOCATE statement must be a variable name76  allocate(proc_ptr2)77  !ERROR: Name in ALLOCATE statement must be a variable name78  allocate(a_var%foo)79  !ERROR: Name in ALLOCATE statement must be a variable name80  allocate(a_var%bar)81 82  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute83  allocate(ed1)84  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute85  allocate(e2)86  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute87  allocate(e3)88  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute89  allocate(e4)90  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute91  allocate(ed5)92  !ERROR: Name in ALLOCATE statement must be a variable name93  allocate(e6)94  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute95  allocate(ed7)96  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute97  allocate(ed7%nok(2))98  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute99  allocate(ed8)100  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute101  allocate(ed8)102  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute103  allocate(edc9%nok)104  !ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute105  allocate(edc10)106  !ERROR: Type-spec in ALLOCATE must not have a deferred type parameter107  allocate(character(:) :: chvar)108 109  ! No errors expected below:110  allocate(a_var)111  allocate(a_var%x)112  allocate(oka1(5, 7), okad1(4, 8), oka2)113  allocate(okp1(5, 7), okpd1(4, 8), okp2)114  allocate(okp1(5, 7), okpd1(4, 8), okp2)115  allocate(okp3, oka3)116  allocate(okac4[2:4,4:*])117  allocate(okacd5(1:2,3:4)[5:*])118  allocate(ed7%ok(7))119  allocate(e8%ok)120  allocate(edc9%ok(4))121  allocate(edc10%ok)122  allocate(rp)123  allocate(character(123) :: chvar)124end subroutine125