]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.fortran/ptype-on-functions.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.fortran / ptype-on-functions.exp
1 # Copyright 2019-2024 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 require allow_fortran_tests
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]} {
28 return
29 }
30
31 set integer4 [fortran_int4]
32 set logical4 [fortran_logical4]
33 set integer8 [fortran_int8]
34
35 # A fortran string parameter is passed as a char *, and an additional
36 # argument str_ for the string length. The type used for the string length
37 # argument is size_t, but for gcc 7 and earlier, the actual type is int
38 # instead ( see
39 # https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html ).
40 set stringlen ($integer8|$integer4)
41
42 if { [test_compiler_info {flang-*} f90] } {
43 set some_module_class_type "Type number"
44 set some_module_aux_info ", $integer8 \\(10\\)"
45 } else {
46 set some_module_class_type "Type __class_some_module_Number(_t)?"
47 set some_module_aux_info ""
48 }
49
50 gdb_test "ptype some_module::get_number" \
51 "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"
52
53 gdb_test "ptype some_module::set_number" \
54 "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"
55
56 gdb_test "ptype is_bigger" \
57 "type = $logical4 \\($integer4, $integer4\\)"
58
59 gdb_test "ptype say_numbers" \
60 "type = void \\($integer4, $integer4, $integer4\\)"
61
62 set fun_ptr_arg "$integer4"
63 if { [test_compiler_info {gfortran-*} f90] } {
64 set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
65 }
66
67 gdb_test "ptype fun_ptr" \
68 "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
69
70 gdb_test "ptype say_string" \
71 "type = void \\(character\[^,\]+, $stringlen\\)"
72
73 set say_array_artificial_first_arg ""
74 if { [test_compiler_info {flang-*} f90] } {
75 set say_array_artificial_first_arg "$integer8, "
76 }
77
78 gdb_test "ptype say_array" \
79 "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"