Home | History | Annotate | Line # | Download | only in gdb.fortran
vla-sub.f90 revision 1.1.1.5
      1 ! Copyright 2015-2023 Free Software Foundation, Inc.
      2 !
      3 ! This program is free software; you can redistribute it and/or modify
      4 ! it under the terms of the GNU General Public License as published by
      5 ! the Free Software Foundation; either version 3 of the License, or
      6 ! (at your option) any later version.
      7 !
      8 ! This program is distributed in the hope that it will be useful,
      9 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
     10 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11 ! GNU General Public License for more details.
     12 !
     13 ! You should have received a copy of the GNU General Public License
     14 ! along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15 !
     16 ! Original file written by Jakub Jelinek <jakub@redhat.com> and
     17 ! Jan Kratochvil <jan.kratochvil@redhat.com>.
     18 ! Modified for the GDB testcases by Keven Boell <keven.boell@intel.com>.
     19 
     20 subroutine foo (array1, array2)
     21   integer :: array1 (:, :)
     22   real    :: array2 (:, :, :)
     23 
     24   array1(:,:) = 5                       ! not-filled
     25   array1(1, 1) = 30
     26 
     27   array2(:,:,:) = 6                     ! array1-filled
     28   array2(:,:,:) = 3
     29   array2(1,1,1) = 30
     30   array2(3,3,3) = 90                    ! array2-almost-filled
     31 end subroutine
     32 
     33 subroutine bar (array1, array2)
     34   integer :: array1 (*)
     35   integer :: array2 (4:9, 10:*)
     36 
     37   array1(5:10) = 1311
     38   array1(7) = 1
     39   array1(100) = 100
     40   array2(4,10) = array1(7)
     41   array2(4,100) = array1(7)
     42   return                                ! end-of-bar
     43 end subroutine
     44 
     45 program vla_sub
     46   interface
     47     subroutine foo (array1, array2)
     48       integer :: array1 (:, :)
     49       real :: array2 (:, :, :)
     50     end subroutine
     51   end interface
     52   interface
     53     subroutine bar (array1, array2)
     54       integer :: array1 (*)
     55       integer :: array2 (4:9, 10:*)
     56     end subroutine
     57   end interface
     58 
     59   real, allocatable :: vla1 (:, :, :)
     60   integer, allocatable :: vla2 (:, :)
     61 
     62   ! used for subroutine
     63   integer :: sub_arr1(42, 42)
     64   real    :: sub_arr2(42, 42, 42)
     65   integer :: sub_arr3(42)
     66 
     67   sub_arr1(:,:) = 1                   ! vla2-deallocated
     68   sub_arr2(:,:,:) = 2
     69   sub_arr3(:) = 3
     70 
     71   call foo(sub_arr1, sub_arr2)
     72   call foo(sub_arr1(5:10, 5:10), sub_arr2(10:15,10:15,10:15))
     73 
     74   allocate (vla1 (10,10,10))
     75   allocate (vla2 (20,20))
     76   vla1(:,:,:) = 1311
     77   vla2(:,:) = 42
     78   call foo(vla2, vla1)
     79 
     80   call bar(sub_arr3, sub_arr1)
     81 end program vla_sub
     82