summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/multiple_allocation_3.f90
blob: 482b388a4d5dff0b5c864fa2724ff549598f40ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
! { dg-do run }
! PR 49755 - If allocating an already allocated array, and stat=
!            is given, set stat to non zero and do not touch the array.
program test
    integer, allocatable :: A(:, :)
    integer :: stat

    allocate(A(20,20))
    A = 42

    ! Allocate of already allocated variable
    allocate (A(5,5), stat=stat)

    ! Expected: Error stat and previous allocation status
    if (stat == 0) call abort ()
    if (any (shape (A) /= [20, 20])) call abort ()
    if (any (A /= 42)) call abort ()
end program