xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.fortran/pointer-to-pointer.exp (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
1*6881a400Schristos# Copyright 2020-2023 Free Software Foundation, Inc.
27d62b00eSchristos
37d62b00eSchristos# This program is free software; you can redistribute it and/or modify
47d62b00eSchristos# it under the terms of the GNU General Public License as published by
57d62b00eSchristos# the Free Software Foundation; either version 3 of the License, or
67d62b00eSchristos# (at your option) any later version.
77d62b00eSchristos#
87d62b00eSchristos# This program is distributed in the hope that it will be useful,
97d62b00eSchristos# but WITHOUT ANY WARRANTY; without even the implied warranty of
107d62b00eSchristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
117d62b00eSchristos# GNU General Public License for more details.
127d62b00eSchristos#
137d62b00eSchristos# You should have received a copy of the GNU General Public License
147d62b00eSchristos# along with this program.  If not, see <http://www.gnu.org/licenses/> .
157d62b00eSchristos
167d62b00eSchristos# Test for GDB printing a pointer to a type containing a buffer.
177d62b00eSchristos
187d62b00eSchristosif {[skip_fortran_tests]} { return -1 }
197d62b00eSchristos
207d62b00eSchristosstandard_testfile ".f90"
217d62b00eSchristosload_lib fortran.exp
227d62b00eSchristos
237d62b00eSchristosif {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
247d62b00eSchristos	 {debug f90}]} {
257d62b00eSchristos    return -1
267d62b00eSchristos}
277d62b00eSchristos
287d62b00eSchristosif ![fortran_runto_main] {
297d62b00eSchristos    return -1
307d62b00eSchristos}
317d62b00eSchristos
32*6881a400Schristos# Depending on the compiler being used, the type names can be printed
33*6881a400Schristos# differently.
347d62b00eSchristosset real4 [fortran_real4]
357d62b00eSchristos
367d62b00eSchristosgdb_breakpoint [gdb_get_line_number "Break Here"]
377d62b00eSchristosgdb_continue_to_breakpoint "Break Here"
387d62b00eSchristos
39*6881a400Schristosgdb_test "print buffer" \
40*6881a400Schristos    " = \\(PTR TO -> \\( Type l_buffer \\)\\) $hex"
41*6881a400Schristosgdb_test "ptype buffer" \
42*6881a400Schristos    [multi_line \
43*6881a400Schristos	 "type = PTR TO -> \\( Type l_buffer" \
44*6881a400Schristos	 "    $real4 :: alpha\\(:\\)" \
45*6881a400Schristos	 "End Type l_buffer \\)" ]
46*6881a400Schristosgdb_test "ptype buffer%alpha" "type = $real4 \\(5\\)"
47*6881a400Schristos
48*6881a400Schristos# GDB allows pointer types to be dereferenced using '*'.  This is not
49*6881a400Schristos# real Fortran syntax, just something extra that GDB supports.
507d62b00eSchristosgdb_test "print *buffer" \
517d62b00eSchristos    " = \\( alpha = \\(1\\.5, 2\\.5, 3\\.5, 4\\.5, 5\\.5\\) \\)"
52*6881a400Schristosgdb_test "ptype *buffer" \
53*6881a400Schristos    [multi_line \
54*6881a400Schristos	 "type = Type l_buffer" \
55*6881a400Schristos	 "    $real4 :: alpha\\(5\\)" \
567d62b00eSchristos	 "End Type l_buffer" ]
57*6881a400Schristosgdb_test "ptype (*buffer)%alpha" "type = $real4 \\(5\\)"
58