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

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