OSDN Git Service

Re-sync to pf3gnuchains3x.
[pf3gnuchains/pf3gnuchains4x.git] / gdb / testsuite / gdb.fortran / types.exp
1 # Copyright 1994, 1995, 1997, 1998, 2007, 2008, 2009
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # This file was adapted from old Chill tests by Stan Shebs
18 # (shebs@cygnus.com).
19
20 if $tracelevel then {
21         strace $tracelevel
22 }
23
24 set prms_id 0
25 set bug_id 0
26
27 # Set the current language to fortran.  This counts as a test.  If it
28 # fails, then we skip the other tests.
29
30 proc set_lang_fortran {} {
31     global gdb_prompt
32     
33     if [gdb_test "set language fortran" ""] {
34         return 0;
35     }
36
37     if ![gdb_test "show language" ".* source language is \"fortran\".*"] {
38         return 1;
39     } else {
40         return 0;
41     }
42 }
43
44 proc test_integer_literal_types_accepted {} {
45     global gdb_prompt
46
47     # Test various decimal values.
48     # Should be integer*4 probably.
49     gdb_test "pt 123" "type = int" 
50 }
51
52 proc test_character_literal_types_accepted {} {
53     global gdb_prompt
54
55     # Test various character values.
56
57     gdb_test "pt 'a'" "type = character\\*1"
58 }
59
60 proc test_integer_literal_types_rejected {} {
61     global gdb_prompt
62
63     test_print_reject "pt _"
64 }
65
66 proc test_logical_literal_types_accepted {} {
67     global gdb_prompt
68
69     # Test the only possible values for a logical, TRUE and FALSE.
70
71     gdb_test "pt .TRUE." "type = logical\\*2"
72     gdb_test "pt .FALSE." "type = logical\\*2"
73 }
74
75 proc test_float_literal_types_accepted {} {
76     global gdb_prompt
77
78     # Test various floating point formats
79
80     # this used to guess whether to look for "real*4" or
81     # "real*8" based on a target config variable, but noone
82     # maintained it properly.
83
84     gdb_test "pt .44" "type = real\\*\[0-9\]+"
85     gdb_test "pt 44.0" "type = real\\*\[0-9\]+"
86     gdb_test "pt 10D20" "type = real\\*\[0-9\]+"
87     gdb_test "pt 10D20" "type = real\\*\[0-9\]+"
88     gdb_test "pt 10d20" "type = real\\*\[0-9\]+"
89     gdb_test "pt 10d20" "type = real\\*\[0-9\]+"
90     gdb_test "pt 10E20" "type = real\\*\[0-9\]+"
91     gdb_test "pt 10E20" "type = real\\*\[0-9\]+"
92     gdb_test "pt 10e20" "type = real\\*\[0-9\]+"
93     gdb_test "pt 10e20" "type = real\\*\[0-9\]+"
94 }
95
96 # Start with a fresh gdb.
97
98 gdb_exit
99 gdb_start
100 gdb_reinitialize_dir $srcdir/$subdir
101
102 gdb_test "set print sevenbit-strings" ""
103
104 if [set_lang_fortran] then {
105     test_integer_literal_types_accepted
106     test_integer_literal_types_rejected
107     test_logical_literal_types_accepted
108     test_character_literal_types_accepted
109     test_float_literal_types_accepted
110 } else {
111     warning "$test_name tests suppressed." 0
112 }