]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.fortran / vla-ptype-sub.exp
1 # Copyright 2015-2023 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 standard_testfile "vla-sub.f90"
17 load_lib "fortran.exp"
18
19 if {[skip_fortran_tests]} { return -1 }
20
21 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
22 {debug f90 quiet}] } {
23 return -1
24 }
25
26 if ![fortran_runto_main] {
27 return -1
28 }
29
30 # Depending on the compiler being used, the type names can be printed differently.
31 set int [fortran_int4]
32 set real [fortran_real4]
33
34 # Pass fixed array to function and handle them as vla in function.
35 gdb_breakpoint [gdb_get_line_number "not-filled"]
36 gdb_continue_to_breakpoint "not-filled (1st)"
37 gdb_test "ptype array1" "type = $int \\\(42,42\\\)" \
38 "ptype array1 (passed fixed)"
39 gdb_test "ptype array2" "type = $real \\\(42,42,42\\\)" \
40 "ptype array2 (passed fixed)"
41 gdb_test "ptype array1(40, 10)" "type = $int" \
42 "ptype array1(40, 10) (passed fixed)"
43 gdb_test "ptype array2(13, 11, 5)" "type = $real" \
44 "ptype array2(13, 11, 5) (passed fixed)"
45
46 # Pass sub arrays to function and handle them as vla in function.
47 gdb_continue_to_breakpoint "not-filled (2nd)"
48 gdb_test "ptype array1" "type = $int \\\(6,6\\\)" \
49 "ptype array1 (passed sub-array)"
50 gdb_test "ptype array2" "type = $real \\\(6,6,6\\\)" \
51 "ptype array2 (passed sub-array)"
52 gdb_test "ptype array1(3, 3)" "type = $int" \
53 "ptype array1(3, 3) (passed sub-array)"
54 gdb_test "ptype array2(4, 4, 4)" "type = $real" \
55 "ptype array2(4, 4, 4) (passed sub-array)"
56
57 # Check ptype outside of bounds. This should not crash GDB.
58 gdb_test "ptype array1(100, 100)" "no such vector element" \
59 "ptype array1(100, 100) subarray do not crash (passed sub-array)"
60 gdb_test "ptype array2(100, 100, 100)" "no such vector element" \
61 "ptype array2(100, 100, 100) subarray do not crash (passed sub-array)"
62
63 # Pass vla to function.
64 gdb_continue_to_breakpoint "not-filled (3rd)"
65 gdb_test "ptype array1" "type = $int \\\(20,20\\\)" \
66 "ptype array1 (passed vla)"
67 gdb_test "ptype array2" "type = $real \\\(10,10,10\\\)" \
68 "ptype array2 (passed vla)"
69 gdb_test "ptype array1(3, 3)" "type = $int" \
70 "ptype array1(3, 3) (passed vla)"
71 gdb_test "ptype array2(4, 4, 4)" "type = $real" \
72 "ptype array2(4, 4, 4) (passed vla)"
73
74 # Check ptype outside of bounds. This should not crash GDB.
75 gdb_test "ptype array1(100, 100)" "no such vector element" \
76 "ptype array1(100, 100) VLA do not crash (passed vla)"
77 gdb_test "ptype array2(100, 100, 100)" "no such vector element" \
78 "ptype array2(100, 100, 100) VLA do not crash (passed vla)"
79
80 # Pass fixed array to function and handle it as VLA of arbitrary length in
81 # function.
82 gdb_breakpoint [gdb_get_line_number "end-of-bar"]
83 gdb_continue_to_breakpoint "end-of-bar"
84 gdb_test "ptype array1" \
85 "type = (PTR TO -> \\( )?$int \\(\\*\\)\\)?" \
86 "ptype array1 (arbitrary length)"
87 gdb_test "ptype array2" \
88 "type = (PTR TO -> \\( )?$int \\(4:9,10:\\*\\)\\)?" \
89 "ptype array2 (arbitrary length)"
90 gdb_test "ptype array1(100)" "type = $int" \
91 "ptype array1(100) (arbitrary length)"
92 gdb_test "ptype array2(4,100)" "type = $int" \
93 "ptype array2(4,100) (arbitrary length)"