Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.fortran / ptype-on-functions.exp
1 # Copyright 2019-2022 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 # This file contains a test for printing the types of functions.
17
18 if { [skip_fortran_tests] } { return -1 }
19
20 standard_testfile .f90
21 load_lib "fortran.exp"
22
23 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
24 return -1
25 }
26
27 if ![fortran_runto_main] then {
28 perror "couldn't run to main"
29 continue
30 }
31
32 set integer4 [fortran_int4]
33 set logical4 [fortran_logical4]
34 set integer8 [fortran_int8]
35
36 # A fortran string parameter is passed as a char *, and an additional
37 # argument str_ for the string length. The type used for the string length
38 # argument is size_t, but for gcc 7 and earlier, the actual type is int
39 # instead ( see
40 # https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html ).
41 set stringlen ($integer8|$integer4)
42
43 if {[test_compiler_info {clang-*}]} {
44 set some_module_class_type "Type number"
45 set some_module_aux_info ", $integer8 \\(10\\)"
46 } else {
47 set some_module_class_type "Type __class_some_module_Number(_t)?"
48 set some_module_aux_info ""
49 }
50
51 gdb_test "ptype some_module::get_number" \
52 "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"
53
54 gdb_test "ptype some_module::set_number" \
55 "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"
56
57 gdb_test "ptype is_bigger" \
58 "type = $logical4 \\($integer4, $integer4\\)"
59
60 gdb_test "ptype say_numbers" \
61 "type = void \\($integer4, $integer4, $integer4\\)"
62
63 set fun_ptr_arg "$integer4"
64 if {[test_compiler_info {gcc-*}]} {
65 set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
66 }
67
68 gdb_test "ptype fun_ptr" \
69 "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
70
71 gdb_test "ptype say_string" \
72 "type = void \\(character\[^,\]+, $stringlen\\)"
73
74 set say_array_artificial_first_arg ""
75 if {[test_compiler_info {clang-*}]} {
76 set say_array_artificial_first_arg "$integer8, "
77 }
78
79 gdb_test "ptype say_array" \
80 "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"
This page took 0.031375 seconds and 4 git commands to generate.