]>
Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2015-2020 Free Software Foundation, Inc. |
3f2f83dd KB |
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" | |
0c13f7e5 | 17 | load_lib "fortran.exp" |
3f2f83dd | 18 | |
a54a7f13 PA |
19 | if {[skip_fortran_tests]} { return -1 } |
20 | ||
5b362f04 | 21 | if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ |
3f2f83dd KB |
22 | {debug f90 quiet}] } { |
23 | return -1 | |
24 | } | |
25 | ||
86cd6bc8 | 26 | if ![fortran_runto_main] { |
3f2f83dd KB |
27 | untested "could not run to main" |
28 | return -1 | |
29 | } | |
30 | ||
0c13f7e5 BH |
31 | # Depending on the compiler being used, the type names can be printed differently. |
32 | set int [fortran_int4] | |
33 | set real [fortran_real4] | |
34 | ||
3f2f83dd KB |
35 | # Pass fixed array to function and handle them as vla in function. |
36 | gdb_breakpoint [gdb_get_line_number "not-filled"] | |
37 | gdb_continue_to_breakpoint "not-filled (1st)" | |
0c13f7e5 | 38 | gdb_test "ptype array1" "type = $int \\\(42,42\\\)" \ |
3f2f83dd | 39 | "ptype array1 (passed fixed)" |
0c13f7e5 | 40 | gdb_test "ptype array2" "type = $real \\\(42,42,42\\\)" \ |
3f2f83dd | 41 | "ptype array2 (passed fixed)" |
0c13f7e5 | 42 | gdb_test "ptype array1(40, 10)" "type = $int" \ |
3f2f83dd | 43 | "ptype array1(40, 10) (passed fixed)" |
0c13f7e5 | 44 | gdb_test "ptype array2(13, 11, 5)" "type = $real" \ |
3f2f83dd KB |
45 | "ptype array2(13, 11, 5) (passed fixed)" |
46 | ||
47 | # Pass sub arrays to function and handle them as vla in function. | |
48 | gdb_continue_to_breakpoint "not-filled (2nd)" | |
0c13f7e5 | 49 | gdb_test "ptype array1" "type = $int \\\(6,6\\\)" \ |
3f2f83dd | 50 | "ptype array1 (passed sub-array)" |
0c13f7e5 | 51 | gdb_test "ptype array2" "type = $real \\\(6,6,6\\\)" \ |
3f2f83dd | 52 | "ptype array2 (passed sub-array)" |
0c13f7e5 | 53 | gdb_test "ptype array1(3, 3)" "type = $int" \ |
3f2f83dd | 54 | "ptype array1(3, 3) (passed sub-array)" |
0c13f7e5 | 55 | gdb_test "ptype array2(4, 4, 4)" "type = $real" \ |
3f2f83dd KB |
56 | "ptype array2(4, 4, 4) (passed sub-array)" |
57 | ||
58 | # Check ptype outside of bounds. This should not crash GDB. | |
59 | gdb_test "ptype array1(100, 100)" "no such vector element" \ | |
60 | "ptype array1(100, 100) subarray do not crash (passed sub-array)" | |
61 | gdb_test "ptype array2(100, 100, 100)" "no such vector element" \ | |
62 | "ptype array2(100, 100, 100) subarray do not crash (passed sub-array)" | |
63 | ||
64 | # Pass vla to function. | |
65 | gdb_continue_to_breakpoint "not-filled (3rd)" | |
0c13f7e5 | 66 | gdb_test "ptype array1" "type = $int \\\(20,20\\\)" \ |
3f2f83dd | 67 | "ptype array1 (passed vla)" |
0c13f7e5 | 68 | gdb_test "ptype array2" "type = $real \\\(10,10,10\\\)" \ |
3f2f83dd | 69 | "ptype array2 (passed vla)" |
0c13f7e5 | 70 | gdb_test "ptype array1(3, 3)" "type = $int" \ |
3f2f83dd | 71 | "ptype array1(3, 3) (passed vla)" |
0c13f7e5 | 72 | gdb_test "ptype array2(4, 4, 4)" "type = $real" \ |
3f2f83dd KB |
73 | "ptype array2(4, 4, 4) (passed vla)" |
74 | ||
75 | # Check ptype outside of bounds. This should not crash GDB. | |
76 | gdb_test "ptype array1(100, 100)" "no such vector element" \ | |
77 | "ptype array1(100, 100) VLA do not crash (passed vla)" | |
78 | gdb_test "ptype array2(100, 100, 100)" "no such vector element" \ | |
79 | "ptype array2(100, 100, 100) VLA do not crash (passed vla)" | |
80 | ||
81 | # Pass fixed array to function and handle it as VLA of arbitrary length in | |
82 | # function. | |
83 | gdb_breakpoint [gdb_get_line_number "end-of-bar"] | |
84 | gdb_continue_to_breakpoint "end-of-bar" | |
85 | gdb_test "ptype array1" \ | |
0c13f7e5 | 86 | "type = (PTR TO -> \\( )?$int \\(\\*\\)\\)?" \ |
3f2f83dd KB |
87 | "ptype array1 (arbitrary length)" |
88 | gdb_test "ptype array2" \ | |
0c13f7e5 | 89 | "type = (PTR TO -> \\( )?$int \\(4:9,10:\\*\\)\\)?" \ |
3f2f83dd | 90 | "ptype array2 (arbitrary length)" |
0c13f7e5 | 91 | gdb_test "ptype array1(100)" "type = $int" \ |
3f2f83dd | 92 | "ptype array1(100) (arbitrary length)" |
0c13f7e5 | 93 | gdb_test "ptype array2(4,100)" "type = $int" \ |
3f2f83dd | 94 | "ptype array2(4,100) (arbitrary length)" |