1 # Copyright 2014-2024 Free Software Foundation, Inc.
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.
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.
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/>.
18 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
26 gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
27 gdb_continue_to_breakpoint "Before pointer assignment"
29 gdb_test "ptype ptr" "= int \\(\\*\\)\\\[variable length\\\]" \
30 "ptype ptr, before pointer assignment"
32 gdb_test "print ptr" "= \\(int \\(\\*\\)\\\[variable length\\\]\\) 0x0" \
33 "print ptr, before pointer assignment"
35 gdb_test "print *ptr" "Cannot access memory at address 0x0" \
36 "print *ptr, before pointer assignment"
38 gdb_breakpoint [gdb_get_line_number "vlas_filled"]
39 gdb_continue_to_breakpoint "vlas_filled"
41 gdb_test "print vla" " = \\{5, 7, 9\\}"
42 gdb_test "print vlaref" " = \\(int \\(&\\)\\\[3\\\]\\) @$hex: \\{5, 7, 9\\}"
43 # The ".*" here is because what gdb emits currently is "const
44 # vlareftypedef", which seems incorrect -- and since that isn't the
45 # bug being tested, it's better not to depend on the exact spelling.
46 gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}"
47 gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}"
48 gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]"
49 gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex"
50 gdb_test "print *ptr" " = \\{5, 7, 9\\}"