d279cd02dee3c1aea2d6f17c438168ad0e3859b2
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.fortran / vla-ptype.exp
1 # Copyright 2015-2021 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.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 untested "could not run to main"
28 return -1
29 }
30
31 # Depending on the compiler being used, the type names can be printed differently.
32 set real [fortran_real4]
33
34 # Check the ptype of various VLA states and pointer to VLA's.
35 gdb_breakpoint [gdb_get_line_number "vla1-init"]
36 gdb_continue_to_breakpoint "vla1-init"
37 gdb_test "ptype vla1" "type = $real, allocatable \\(:,:,:\\)" "ptype vla1 not initialized"
38 gdb_test "ptype vla2" "type = $real, allocatable \\(:,:,:\\)" "ptype vla2 not initialized"
39 gdb_test "ptype pvla" "type = $real \\(:,:,:\\)" "ptype pvla not initialized"
40 gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
41 "ptype vla1(3, 6, 9) not initialized"
42 gdb_test "ptype vla2(5, 45, 20)" \
43 "no such vector element \\\(vector not allocated\\\)" \
44 "ptype vla2(5, 45, 20) not initialized"
45
46 gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
47 gdb_continue_to_breakpoint "vla1-allocated"
48 gdb_test "ptype vla1" "type = $real, allocatable \\\(10,10,10\\\)" \
49 "ptype vla1 allocated"
50
51 gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
52 gdb_continue_to_breakpoint "vla2-allocated"
53 gdb_test "ptype vla2" "type = $real, allocatable \\\(7,42:50,13:35\\\)" \
54 "ptype vla2 allocated"
55
56 gdb_breakpoint [gdb_get_line_number "vla1-filled"]
57 gdb_continue_to_breakpoint "vla1-filled"
58 gdb_test "ptype vla1" "type = $real, allocatable \\\(10,10,10\\\)" \
59 "ptype vla1 filled"
60 gdb_test "ptype vla1(3, 6, 9)" "type = $real"
61
62 gdb_breakpoint [gdb_get_line_number "vla2-filled"]
63 gdb_continue_to_breakpoint "vla2-filled"
64 gdb_test "ptype vla2" "type = $real, allocatable \\\(7,42:50,13:35\\\)" \
65 "ptype vla2 filled"
66 gdb_test "ptype vla2(5, 45, 20)" "type = $real" \
67 "ptype vla2(5, 45, 20) filled"
68
69 gdb_breakpoint [gdb_get_line_number "pvla-associated"]
70 gdb_continue_to_breakpoint "pvla-associated"
71 gdb_test "ptype pvla" "type = $real \\\(10,10,10\\\)" \
72 "ptype pvla associated"
73 gdb_test "ptype pvla(3, 6, 9)" "type = $real"
74
75 gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
76 gdb_continue_to_breakpoint "pvla-re-associated"
77 gdb_test "ptype pvla" "type = $real \\\(7,42:50,13:35\\\)" \
78 "ptype pvla re-associated"
79 gdb_test "ptype vla2(5, 45, 20)" "type = $real" \
80 "ptype vla2(5, 45, 20) re-associated"
81
82 gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
83 gdb_continue_to_breakpoint "pvla-deassociated"
84 gdb_test "ptype pvla" "type = $real \\(:,:,:\\)" "ptype pvla deassociated"
85 gdb_test "ptype pvla(5, 45, 20)" \
86 "no such vector element \\\(vector not associated\\\)" \
87 "ptype pvla(5, 45, 20) not associated"
88
89 gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
90 gdb_continue_to_breakpoint "vla1-deallocated"
91 gdb_test "ptype vla1" "type = $real, allocatable \\(:,:,:\\)" "ptype vla1 not allocated"
92 gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
93 "ptype vla1(3, 6, 9) not allocated"
94
95 gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
96 gdb_continue_to_breakpoint "vla2-deallocated"
97 gdb_test "ptype vla2" "type = $real, allocatable \\(:,:,:\\)" "ptype vla2 not allocated"
98 gdb_test "ptype vla2(5, 45, 20)" \
99 "no such vector element \\\(vector not allocated\\\)" \
100 "ptype vla2(5, 45, 20) not allocated"
101
102 gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds-v1"]
103 gdb_continue_to_breakpoint "vla1-neg-bounds-v1"
104 gdb_test "ptype vla1" \
105 "type = $real, allocatable \\(-2:-1,-5:-2,-3:-1\\)" \
106 "ptype vla1 negative bounds"
107
108 gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds-v2"]
109 gdb_continue_to_breakpoint "vla1-neg-bounds-v2"
110 gdb_test "ptype vla1" \
111 "type = $real, allocatable \\(-2:1,-5:2,-3:1\\)" \
112 "ptype vla1 negative lower bounds, positive upper bounds"
This page took 0.03163 seconds and 3 git commands to generate.