Blame SOURCES/gdb-vla-intel-tests.patch

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