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

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