7306e88
Index: gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-func.exp
7306e88
===================================================================
7306e88
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
7306e88
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-func.exp	2016-01-08 19:15:44.983637680 +0100
7306e88
@@ -0,0 +1,61 @@
7306e88
+# Copyright 2014 Free Software Foundation, Inc.
7306e88
+
7306e88
+# This program is free software; you can redistribute it and/or modify
7306e88
+# it under the terms of the GNU General Public License as published by
7306e88
+# the Free Software Foundation; either version 3 of the License, or
7306e88
+# (at your option) any later version.
7306e88
+#
7306e88
+# This program is distributed in the hope that it will be useful,
7306e88
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
7306e88
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7306e88
+# GNU General Public License for more details.
7306e88
+#
7306e88
+# You should have received a copy of the GNU General Public License
7306e88
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7306e88
+
7306e88
+standard_testfile ".f90"
7306e88
+
7306e88
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
7306e88
+    {debug f90 quiet}] } {
7306e88
+    return -1
7306e88
+}
7306e88
+
7306e88
+if ![runto MAIN__] then {
7306e88
+    perror "couldn't run to breakpoint MAIN__"
7306e88
+    continue
7306e88
+}
7306e88
+
7306e88
+# Check VLA passed to first Fortran function.
7306e88
+gdb_breakpoint [gdb_get_line_number "func1-vla-passed"]
7306e88
+gdb_continue_to_breakpoint "func1-vla-passed"
7306e88
+gdb_test "print vla" " = \\( *\\( *22, *22, *22,\[()22, .\]*\\)" \
7306e88
+  "print vla (func1)"
7306e88
+gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10,10\\\)" \
7306e88
+  "ptype vla (func1)"
7306e88
+
7306e88
+gdb_breakpoint [gdb_get_line_number "func1-vla-modified"]
7306e88
+gdb_continue_to_breakpoint "func1-vla-modified"
7306e88
+gdb_test "print vla(5,5)" " = 55" "print vla(5,5) (func1)"
7306e88
+gdb_test "print vla(7,7)" " = 77" "print vla(5,5) (func1)"
7306e88
+
7306e88
+# Check if the values are correct after returning from func1
7306e88
+gdb_breakpoint [gdb_get_line_number "func1-returned"]
7306e88
+gdb_continue_to_breakpoint "func1-returned"
7306e88
+gdb_test "print ret" " = .TRUE." "print ret after func1 returned"
7306e88
+
7306e88
+# Check VLA passed to second Fortran function
7306e88
+gdb_breakpoint [gdb_get_line_number "func2-vla-passed"]
7306e88
+gdb_continue_to_breakpoint "func2-vla-passed"
7306e88
+gdb_test "print vla" \
7306e88
+  " = \\\(44, 44, 44, 44, 44, 44, 44, 44, 44, 44\\\)" \
7306e88
+  "print vla (func2)"
7306e88
+gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
7306e88
+  "ptype vla (func2)"
7306e88
+
7306e88
+# Check if the returned VLA has the correct values and ptype.
7306e88
+gdb_breakpoint [gdb_get_line_number "func2-returned"]
7306e88
+gdb_continue_to_breakpoint "func2-returned"
7306e88
+gdb_test "print vla3" " = \\\(1, 2, 44, 4, 44, 44, 44, 8, 44, 44\\\)" \
7306e88
+  "print vla3 (after func2)"
7306e88
+gdb_test "ptype vla3" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
7306e88
+  "ptype vla3 (after func2)"
7306e88
Index: gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-func.f90
7306e88
===================================================================
7306e88
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
7306e88
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-func.f90	2016-01-08 19:15:44.983637680 +0100
7306e88
@@ -0,0 +1,71 @@
7306e88
+! Copyright 2014 Free Software Foundation, Inc.
7306e88
+!
7306e88
+! This program is free software; you can redistribute it and/or modify
7306e88
+! it under the terms of the GNU General Public License as published by
7306e88
+! the Free Software Foundation; either version 2 of the License, or
7306e88
+! (at your option) any later version.
7306e88
+!
7306e88
+! This program is distributed in the hope that it will be useful,
7306e88
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
7306e88
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7306e88
+! GNU General Public License for more details.
7306e88
+!
7306e88
+! You should have received a copy of the GNU General Public License
7306e88
+! along with this program; if not, write to the Free Software
7306e88
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
7306e88
+
7306e88
+logical function func1 (vla)
7306e88
+  implicit none
7306e88
+  integer, allocatable :: vla (:, :)
7306e88
+  func1 = allocated(vla)
7306e88
+  vla(5,5) = 55               ! func1-vla-passed
7306e88
+  vla(7,7) = 77
7306e88
+  return                      ! func1-vla-modified
7306e88
+end function func1
7306e88
+
7306e88
+function func2(vla)
7306e88
+  implicit none
7306e88
+  integer :: vla (:)
7306e88
+  integer :: func2(size(vla))
7306e88
+  integer :: k
7306e88
+
7306e88
+  vla(1) = 1                    ! func2-vla-passed
7306e88
+  vla(2) = 2
7306e88
+  vla(4) = 4
7306e88
+  vla(8) = 8
7306e88
+
7306e88
+  func2 = vla
7306e88
+end function func2
7306e88
+
7306e88
+program vla_func
7306e88
+  implicit none
7306e88
+  interface
7306e88
+    logical function func1 (vla)
7306e88
+      integer :: vla (:, :)
7306e88
+    end function
7306e88
+  end interface
7306e88
+  interface
7306e88
+    function func2 (vla)
7306e88
+      integer :: vla (:)
7306e88
+      integer func2(size(vla))
7306e88
+    end function
7306e88
+  end interface
7306e88
+
7306e88
+  logical :: ret
7306e88
+  integer, allocatable :: vla1 (:, :)
7306e88
+  integer, allocatable :: vla2 (:)
7306e88
+  integer, allocatable :: vla3 (:)
7306e88
+
7306e88
+  ret = .FALSE.
7306e88
+
7306e88
+  allocate (vla1 (10,10))
7306e88
+  vla1(:,:) = 22
7306e88
+
7306e88
+  allocate (vla2 (10))
7306e88
+  vla2(:) = 44
7306e88
+
7306e88
+  ret = func1(vla1)
7306e88
+  vla3 = func2(vla2)          ! func1-returned
7306e88
+
7306e88
+  ret = .TRUE.                ! func2-returned
7306e88
+end program vla_func
7306e88
Index: gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-stringsold.exp
7306e88
===================================================================
7306e88
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
7306e88
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-stringsold.exp	2016-01-08 19:15:44.984637686 +0100
7306e88
@@ -0,0 +1,101 @@
7306e88
+# Copyright 2014 Free Software Foundation, Inc.
7306e88
+
7306e88
+# This program is free software; you can redistribute it and/or modify
7306e88
+# it under the terms of the GNU General Public License as published by
7306e88
+# the Free Software Foundation; either version 3 of the License, or
7306e88
+# (at your option) any later version.
7306e88
+#
7306e88
+# This program is distributed in the hope that it will be useful,
7306e88
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
7306e88
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7306e88
+# GNU General Public License for more details.
7306e88
+#
7306e88
+# You should have received a copy of the GNU General Public License
7306e88
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7306e88
+
7306e88
+standard_testfile ".f90"
7306e88
+
7306e88
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
7306e88
+    {debug f90 quiet}] } {
7306e88
+    return -1
7306e88
+}
7306e88
+
7306e88
+# check that all fortran standard datatypes will be
7306e88
+# handled correctly when using as VLA's
7306e88
+
7306e88
+if ![runto MAIN__] then {
7306e88
+    perror "couldn't run to breakpoint MAIN__"
7306e88
+    continue
7306e88
+}
7306e88
+
7306e88
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
7306e88
+gdb_continue_to_breakpoint "var_char-allocated-1"
7306e88
+gdb_test "print var_char" \
7306e88
+  " = \\(PTR TO -> \\( character\\*10 \\)\\) ${hex}" \
7306e88
+  "print var_char after allocated first time"
7306e88
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*10 \\)" \
7306e88
+  "whatis var_char first time"
7306e88
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*10 \\)" \
7306e88
+  "ptype var_char first time"
7306e88
+gdb_test "next" "\\d+.*var_char = 'foo'.*" \
7306e88
+  "next to allocation status of var_char"
7306e88
+gdb_test "print l" " = .TRUE." "print allocation status first time"
7306e88
+
7306e88
+gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
7306e88
+gdb_continue_to_breakpoint "var_char-filled-1"
7306e88
+gdb_test "print var_char" \
7306e88
+  " = \\(PTR TO -> \\( character\\*3 \\)\\) ${hex}" \
7306e88
+  "print var_char after filled first time"
7306e88
+gdb_test "print *var_char" " = 'foo'" \
7306e88
+  "print *var_char after filled first time"
7306e88
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*3 \\)" \
7306e88
+  "whatis var_char after filled first time"
7306e88
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*3 \\)" \
7306e88
+  "ptype var_char after filled first time"
7306e88
+gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
7306e88
+gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"
7306e88
+
7306e88
+gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
7306e88
+gdb_continue_to_breakpoint "var_char-filled-2"
7306e88
+gdb_test "print var_char" \
7306e88
+  " = \\(PTR TO -> \\( character\\*6 \\)\\) ${hex}" \
7306e88
+  "print var_char after allocated second time"
7306e88
+gdb_test "print *var_char" " = 'foobar'" \
7306e88
+  "print *var_char after allocated second time"
7306e88
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*6 \\)" \
7306e88
+  "whatis var_char second time"
7306e88
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*6 \\)" \
7306e88
+  "ptype var_char second time"
7306e88
+
7306e88
+gdb_breakpoint [gdb_get_line_number "var_char-empty"]
7306e88
+gdb_continue_to_breakpoint "var_char-empty"
7306e88
+gdb_test "print var_char" \
7306e88
+  " = \\(PTR TO -> \\( character\\*0 \\)\\) ${hex}" \
7306e88
+  "print var_char after set empty"
7306e88
+gdb_test "print *var_char" " = \"\"" "print *var_char after set empty"
7306e88
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*0 \\)" \
7306e88
+  "whatis var_char after set empty"
7306e88
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*0 \\)" \
7306e88
+  "ptype var_char after set empty"
7306e88
+
7306e88
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-3"]
7306e88
+gdb_continue_to_breakpoint "var_char-allocated-3"
7306e88
+gdb_test "print var_char" \
7306e88
+  " = \\(PTR TO -> \\( character\\*21 \\)\\) ${hex}" \
7306e88
+  "print var_char after allocated third time"
7306e88
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*21 \\)" \
7306e88
+  "whatis var_char after allocated third time"
7306e88
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*21 \\)" \
7306e88
+  "ptype var_char after allocated third time"
7306e88
+
7306e88
+gdb_breakpoint [gdb_get_line_number "var_char_p-associated"]
7306e88
+gdb_continue_to_breakpoint "var_char_p-associated"
7306e88
+gdb_test "print var_char_p" \
7306e88
+  " = \\(PTR TO -> \\( character\\*7 \\)\\) ${hex}" \
7306e88
+  "print var_char_p after associated"
7306e88
+gdb_test "print *var_char_p" " = 'johndoe'" \
7306e88
+  "print *var_char_ after associated"
7306e88
+gdb_test "whatis var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
7306e88
+  "whatis var_char_p after associated"
7306e88
+gdb_test "ptype var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
7306e88
+  "ptype var_char_p after associated"
7306e88
Index: gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-stringsold.f90
7306e88
===================================================================
7306e88
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
7306e88
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-stringsold.f90	2016-01-08 19:15:44.984637686 +0100
7306e88
@@ -0,0 +1,40 @@
7306e88
+! Copyright 2014 Free Software Foundation, Inc.
7306e88
+!
7306e88
+! This program is free software; you can redistribute it and/or modify
7306e88
+! it under the terms of the GNU General Public License as published by
7306e88
+! the Free Software Foundation; either version 2 of the License, or
7306e88
+! (at your option) any later version.
7306e88
+!
7306e88
+! This program is distributed in the hope that it will be useful,
7306e88
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
7306e88
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7306e88
+! GNU General Public License for more details.
7306e88
+!
7306e88
+! You should have received a copy of the GNU General Public License
7306e88
+! along with this program; if not, write to the Free Software
7306e88
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
7306e88
+
7306e88
+program vla_strings
7306e88
+  character(len=:), target, allocatable   :: var_char
7306e88
+  character(len=:), pointer               :: var_char_p
7306e88
+  logical                                 :: l
7306e88
+
7306e88
+  allocate(character(len=10) :: var_char)
7306e88
+  l = allocated(var_char)                 ! var_char-allocated-1
7306e88
+  var_char = 'foo'
7306e88
+  deallocate(var_char)                    ! var_char-filled-1
7306e88
+  l = allocated(var_char)                 ! var_char-deallocated
7306e88
+  allocate(character(len=42) :: var_char)
7306e88
+  l = allocated(var_char)
7306e88
+  var_char = 'foobar'
7306e88
+  var_char = ''                           ! var_char-filled-2
7306e88
+  var_char = 'bar'                        ! var_char-empty
7306e88
+  deallocate(var_char)
7306e88
+  allocate(character(len=21) :: var_char)
7306e88
+  l = allocated(var_char)                 ! var_char-allocated-3
7306e88
+  var_char = 'johndoe'
7306e88
+  var_char_p => var_char
7306e88
+  l = associated(var_char_p)              ! var_char_p-associated
7306e88
+  var_char_p => null()
7306e88
+  l = associated(var_char_p)              ! var_char_p-not-associated
7306e88
+end program vla_strings