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

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