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

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