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

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