1 From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
2 From: Fedora GDB patches <invalid@email.com>
3 Date: Fri, 27 Oct 2017 21:07:50 +0200
4 Subject: gdb-vla-intel-tests.patch
6 FileName: gdb-vla-intel-tests.patch
10 gdb/testsuite/gdb.fortran/vla-func.exp | 61 ++++++++++++++++
11 gdb/testsuite/gdb.fortran/vla-func.f90 | 71 +++++++++++++++++++
12 gdb/testsuite/gdb.fortran/vla-stringsold.exp | 101 +++++++++++++++++++++++++++
13 gdb/testsuite/gdb.fortran/vla-stringsold.f90 | 40 +++++++++++
14 4 files changed, 273 insertions(+)
15 create mode 100644 gdb/testsuite/gdb.fortran/vla-func.exp
16 create mode 100644 gdb/testsuite/gdb.fortran/vla-func.f90
17 create mode 100644 gdb/testsuite/gdb.fortran/vla-stringsold.exp
18 create mode 100644 gdb/testsuite/gdb.fortran/vla-stringsold.f90
20 diff --git a/gdb/testsuite/gdb.fortran/vla-func.exp b/gdb/testsuite/gdb.fortran/vla-func.exp
22 index 0000000000..f0f236bef0
24 +++ b/gdb/testsuite/gdb.fortran/vla-func.exp
26 +# Copyright 2014 Free Software Foundation, Inc.
28 +# This program is free software; you can redistribute it and/or modify
29 +# it under the terms of the GNU General Public License as published by
30 +# the Free Software Foundation; either version 3 of the License, or
31 +# (at your option) any later version.
33 +# This program is distributed in the hope that it will be useful,
34 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
35 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 +# GNU General Public License for more details.
38 +# You should have received a copy of the GNU General Public License
39 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
41 +standard_testfile ".f90"
43 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
44 + {debug f90 quiet}] } {
48 +if ![runto MAIN__] then {
49 + perror "couldn't run to breakpoint MAIN__"
53 +# Check VLA passed to first Fortran function.
54 +gdb_breakpoint [gdb_get_line_number "func1-vla-passed"]
55 +gdb_continue_to_breakpoint "func1-vla-passed"
56 +gdb_test "print vla" " = \\( *\\( *22, *22, *22,\[()22, .\]*\\)" \
58 +gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10,10\\\)" \
61 +gdb_breakpoint [gdb_get_line_number "func1-vla-modified"]
62 +gdb_continue_to_breakpoint "func1-vla-modified"
63 +gdb_test "print vla(5,5)" " = 55" "print vla(5,5) (func1)"
64 +gdb_test "print vla(7,7)" " = 77" "print vla(5,5) (func1)"
66 +# Check if the values are correct after returning from func1
67 +gdb_breakpoint [gdb_get_line_number "func1-returned"]
68 +gdb_continue_to_breakpoint "func1-returned"
69 +gdb_test "print ret" " = .TRUE." "print ret after func1 returned"
71 +# Check VLA passed to second Fortran function
72 +gdb_breakpoint [gdb_get_line_number "func2-vla-passed"]
73 +gdb_continue_to_breakpoint "func2-vla-passed"
74 +gdb_test "print vla" \
75 + " = \\\(44, 44, 44, 44, 44, 44, 44, 44, 44, 44\\\)" \
77 +gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
80 +# Check if the returned VLA has the correct values and ptype.
81 +gdb_breakpoint [gdb_get_line_number "func2-returned"]
82 +gdb_continue_to_breakpoint "func2-returned"
83 +gdb_test "print vla3" " = \\\(1, 2, 44, 4, 44, 44, 44, 8, 44, 44\\\)" \
84 + "print vla3 (after func2)"
85 +gdb_test "ptype vla3" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
86 + "ptype vla3 (after func2)"
87 diff --git a/gdb/testsuite/gdb.fortran/vla-func.f90 b/gdb/testsuite/gdb.fortran/vla-func.f90
89 index 0000000000..7540f54dbb
91 +++ b/gdb/testsuite/gdb.fortran/vla-func.f90
93 +! Copyright 2014 Free Software Foundation, Inc.
95 +! This program is free software; you can redistribute it and/or modify
96 +! it under the terms of the GNU General Public License as published by
97 +! the Free Software Foundation; either version 2 of the License, or
98 +! (at your option) any later version.
100 +! This program is distributed in the hope that it will be useful,
101 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
102 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
103 +! GNU General Public License for more details.
105 +! You should have received a copy of the GNU General Public License
106 +! along with this program; if not, write to the Free Software
107 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
109 +logical function func1 (vla)
111 + integer, allocatable :: vla (:, :)
112 + func1 = allocated(vla)
113 + vla(5,5) = 55 ! func1-vla-passed
115 + return ! func1-vla-modified
121 + integer :: func2(size(vla))
124 + vla(1) = 1 ! func2-vla-passed
135 + logical function func1 (vla)
136 + integer, allocatable :: vla (:, :)
140 + function func2 (vla)
142 + integer func2(size(vla))
147 + integer, allocatable :: vla1 (:, :)
148 + integer, allocatable :: vla2 (:)
149 + integer, allocatable :: vla3 (:)
153 + allocate (vla1 (10,10))
156 + allocate (vla2 (10))
160 + vla3 = func2(vla2) ! func1-returned
162 + ret = .TRUE. ! func2-returned
163 +end program vla_func
164 diff --git a/gdb/testsuite/gdb.fortran/vla-stringsold.exp b/gdb/testsuite/gdb.fortran/vla-stringsold.exp
166 index 0000000000..c1bf7ef763
168 +++ b/gdb/testsuite/gdb.fortran/vla-stringsold.exp
170 +# Copyright 2014 Free Software Foundation, Inc.
172 +# This program is free software; you can redistribute it and/or modify
173 +# it under the terms of the GNU General Public License as published by
174 +# the Free Software Foundation; either version 3 of the License, or
175 +# (at your option) any later version.
177 +# This program is distributed in the hope that it will be useful,
178 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
179 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
180 +# GNU General Public License for more details.
182 +# You should have received a copy of the GNU General Public License
183 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
185 +standard_testfile ".f90"
187 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
188 + {debug f90 quiet}] } {
192 +# check that all fortran standard datatypes will be
193 +# handled correctly when using as VLA's
195 +if ![runto MAIN__] then {
196 + perror "couldn't run to breakpoint MAIN__"
200 +gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
201 +gdb_continue_to_breakpoint "var_char-allocated-1"
202 +gdb_test "print var_char" \
203 + " = \\(PTR TO -> \\( character\\*10 \\)\\) ${hex}" \
204 + "print var_char after allocated first time"
205 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*10 \\)" \
206 + "whatis var_char first time"
207 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*10 \\)" \
208 + "ptype var_char first time"
209 +gdb_test "next" "\\d+.*var_char = 'foo'.*" \
210 + "next to allocation status of var_char"
211 +gdb_test "print l" " = .TRUE." "print allocation status first time"
213 +gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
214 +gdb_continue_to_breakpoint "var_char-filled-1"
215 +gdb_test "print var_char" \
216 + " = \\(PTR TO -> \\( character\\*3 \\)\\) ${hex}" \
217 + "print var_char after filled first time"
218 +gdb_test "print *var_char" " = 'foo'" \
219 + "print *var_char after filled first time"
220 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*3 \\)" \
221 + "whatis var_char after filled first time"
222 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*3 \\)" \
223 + "ptype var_char after filled first time"
224 +gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
225 +gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"
227 +gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
228 +gdb_continue_to_breakpoint "var_char-filled-2"
229 +gdb_test "print var_char" \
230 + " = \\(PTR TO -> \\( character\\*6 \\)\\) ${hex}" \
231 + "print var_char after allocated second time"
232 +gdb_test "print *var_char" " = 'foobar'" \
233 + "print *var_char after allocated second time"
234 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*6 \\)" \
235 + "whatis var_char second time"
236 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*6 \\)" \
237 + "ptype var_char second time"
239 +gdb_breakpoint [gdb_get_line_number "var_char-empty"]
240 +gdb_continue_to_breakpoint "var_char-empty"
241 +gdb_test "print var_char" \
242 + " = \\(PTR TO -> \\( character\\*0 \\)\\) ${hex}" \
243 + "print var_char after set empty"
244 +gdb_test "print *var_char" " = \"\"" "print *var_char after set empty"
245 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*0 \\)" \
246 + "whatis var_char after set empty"
247 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*0 \\)" \
248 + "ptype var_char after set empty"
250 +gdb_breakpoint [gdb_get_line_number "var_char-allocated-3"]
251 +gdb_continue_to_breakpoint "var_char-allocated-3"
252 +gdb_test "print var_char" \
253 + " = \\(PTR TO -> \\( character\\*21 \\)\\) ${hex}" \
254 + "print var_char after allocated third time"
255 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*21 \\)" \
256 + "whatis var_char after allocated third time"
257 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*21 \\)" \
258 + "ptype var_char after allocated third time"
260 +gdb_breakpoint [gdb_get_line_number "var_char_p-associated"]
261 +gdb_continue_to_breakpoint "var_char_p-associated"
262 +gdb_test "print var_char_p" \
263 + " = \\(PTR TO -> \\( character\\*7 \\)\\) ${hex}" \
264 + "print var_char_p after associated"
265 +gdb_test "print *var_char_p" " = 'johndoe'" \
266 + "print *var_char_ after associated"
267 +gdb_test "whatis var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
268 + "whatis var_char_p after associated"
269 +gdb_test "ptype var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
270 + "ptype var_char_p after associated"
271 diff --git a/gdb/testsuite/gdb.fortran/vla-stringsold.f90 b/gdb/testsuite/gdb.fortran/vla-stringsold.f90
273 index 0000000000..0a1d5221d0
275 +++ b/gdb/testsuite/gdb.fortran/vla-stringsold.f90
277 +! Copyright 2014 Free Software Foundation, Inc.
279 +! This program is free software; you can redistribute it and/or modify
280 +! it under the terms of the GNU General Public License as published by
281 +! the Free Software Foundation; either version 2 of the License, or
282 +! (at your option) any later version.
284 +! This program is distributed in the hope that it will be useful,
285 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
286 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
287 +! GNU General Public License for more details.
289 +! You should have received a copy of the GNU General Public License
290 +! along with this program; if not, write to the Free Software
291 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
294 + character(len=:), target, allocatable :: var_char
295 + character(len=:), pointer :: var_char_p
298 + allocate(character(len=10) :: var_char)
299 + l = allocated(var_char) ! var_char-allocated-1
301 + deallocate(var_char) ! var_char-filled-1
302 + l = allocated(var_char) ! var_char-deallocated
303 + allocate(character(len=42) :: var_char)
304 + l = allocated(var_char)
305 + var_char = 'foobar'
306 + var_char = '' ! var_char-filled-2
307 + var_char = 'bar' ! var_char-empty
308 + deallocate(var_char)
309 + allocate(character(len=21) :: var_char)
310 + l = allocated(var_char) ! var_char-allocated-3
311 + var_char = 'johndoe'
312 + var_char_p => var_char
313 + l = associated(var_char_p) ! var_char_p-associated
314 + var_char_p => null()
315 + l = associated(var_char_p) ! var_char_p-not-associated
316 +end program vla_strings