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

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