]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 1994-2023 Free Software Foundation, Inc. |
c906108c SS |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
b304d130 AC |
16 | # This file was adapted from old Chill tests by Stan Shebs |
17 | # (shebs@cygnus.com). | |
c906108c | 18 | |
f1208f9e | 19 | load_lib "fortran.exp" |
c906108c | 20 | |
f1208f9e | 21 | if { [skip_fortran_tests] } { continue } |
c906108c SS |
22 | |
23 | proc test_integer_literal_types_accepted {} { | |
24 | global gdb_prompt | |
25 | ||
26 | # Test various decimal values. | |
27 | # Should be integer*4 probably. | |
28 | gdb_test "pt 123" "type = int" | |
29 | } | |
30 | ||
31 | proc test_character_literal_types_accepted {} { | |
32 | global gdb_prompt | |
33 | ||
34 | # Test various character values. | |
35 | ||
36 | gdb_test "pt 'a'" "type = character\\*1" | |
37 | } | |
38 | ||
39 | proc test_integer_literal_types_rejected {} { | |
40 | global gdb_prompt | |
41 | ||
42 | test_print_reject "pt _" | |
43 | } | |
44 | ||
45 | proc test_logical_literal_types_accepted {} { | |
46 | global gdb_prompt | |
47 | ||
dd9f2c76 AB |
48 | # Test the only possible values for a logical, TRUE and FALSE (and |
49 | # also true and false). | |
c906108c | 50 | |
4ec8aa9e NCK |
51 | gdb_test "pt .TRUE." "type = logical\\*4" |
52 | gdb_test "pt .FALSE." "type = logical\\*4" | |
53 | gdb_test "pt .true." "type = logical\\*4" | |
54 | gdb_test "pt .false." "type = logical\\*4" | |
c906108c SS |
55 | } |
56 | ||
57 | proc test_float_literal_types_accepted {} { | |
58 | global gdb_prompt | |
59 | ||
60 | # Test various floating point formats | |
61 | ||
62 | # this used to guess whether to look for "real*4" or | |
63 | # "real*8" based on a target config variable, but noone | |
64 | # maintained it properly. | |
65 | ||
66 | gdb_test "pt .44" "type = real\\*\[0-9\]+" | |
67 | gdb_test "pt 44.0" "type = real\\*\[0-9\]+" | |
68 | gdb_test "pt 10D20" "type = real\\*\[0-9\]+" | |
c906108c SS |
69 | gdb_test "pt 10d20" "type = real\\*\[0-9\]+" |
70 | gdb_test "pt 10E20" "type = real\\*\[0-9\]+" | |
c906108c SS |
71 | gdb_test "pt 10e20" "type = real\\*\[0-9\]+" |
72 | } | |
73 | ||
adc29023 NCK |
74 | # Test the default primitive Fortran types. |
75 | proc test_default_types {} { | |
87abd982 NCK |
76 | gdb_test "ptype integer" "type = integer\\*4" |
77 | gdb_test "ptype logical" "type = logical\\*4" | |
78 | gdb_test "ptype real" "type = real\\*4" | |
79 | gdb_test "ptype complex" "type = complex\\*4" | |
adc29023 NCK |
80 | } |
81 | ||
7bea47f0 AB |
82 | # Test the the primitive Fortran types, those that GDB should always |
83 | # know, even if the program does not define them, are in fact, known. | |
84 | proc test_primitive_types_known {} { | |
adc29023 | 85 | foreach type {void character \ |
87abd982 NCK |
86 | integer*1 integer*2 integer*4 integer*8 \ |
87 | integer_1 integer_2 integer_4 integer_8 \ | |
adc29023 NCK |
88 | logical*1 logical*2 logical*4 logical*8 \ |
89 | logical_1 logical_2 logical_4 logical_8 \ | |
87abd982 | 90 | real*4 real*8 real*16 real_4 real_8 real_16 \ |
adc29023 NCK |
91 | complex*4 complex*8 complex*16 \ |
92 | complex_4 complex_8 complex_16} { | |
93 | ||
94 | # While TYPE_KIND is allowed as input, GDB will always return the | |
95 | # Fortran notation TYPE*KIND | |
96 | regsub -all "_" $type "\*" type_res | |
97 | gdb_test "ptype $type" [string_to_regexp "type = $type_res"] | |
7bea47f0 AB |
98 | } |
99 | } | |
100 | ||
c906108c SS |
101 | # Start with a fresh gdb. |
102 | ||
103 | gdb_exit | |
104 | gdb_start | |
105 | gdb_reinitialize_dir $srcdir/$subdir | |
106 | ||
107 | gdb_test "set print sevenbit-strings" "" | |
108 | ||
49bb4744 | 109 | if {[set_lang_fortran]} { |
7bea47f0 | 110 | test_primitive_types_known |
adc29023 | 111 | test_default_types |
c906108c SS |
112 | test_integer_literal_types_accepted |
113 | test_integer_literal_types_rejected | |
114 | test_logical_literal_types_accepted | |
115 | test_character_literal_types_accepted | |
116 | test_float_literal_types_accepted | |
117 | } else { | |
118 | warning "$test_name tests suppressed." 0 | |
119 | } |