Commit | Line | Data |
---|---|---|
00d5215e UW |
1 | # Copyright 2016 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 is part of the gdb testsuite. It is intended to test that | |
17 | # gdb could correctly handle floating point constant with a suffix. | |
18 | ||
19 | standard_testfile .c | |
20 | ||
21 | proc do_compile { {opts {}} } { | |
22 | global srcdir subdir srcfile binfile | |
23 | set ccopts {debug quiet} | |
24 | foreach opt $opts {lappend ccopts "additional_flags=$opt"} | |
25 | gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable $ccopts | |
26 | } | |
27 | ||
28 | if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } { | |
29 | untested "compiler can't handle __float128 type?" | |
30 | return -1 | |
31 | } | |
32 | ||
33 | clean_restart ${binfile} | |
34 | ||
35 | if ![runto_main] then { | |
36 | perror "couldn't run to breakpoint" | |
37 | continue | |
38 | } | |
39 | ||
40 | # Run to the breakpoint at return. | |
41 | gdb_breakpoint [gdb_get_line_number "return"] | |
42 | gdb_continue_to_breakpoint "return" | |
43 | ||
44 | # Print the original value of ld and f128 | |
45 | gdb_test "print ld" ".* = 1\\.375.*" "The original value of ld is 1.375" | |
46 | gdb_test "print f128" ".* = 2\\.375.*" "The original value of f128 is 2.375" | |
47 | ||
48 | # Test that gdb could correctly recognize float constant expression with a suffix. | |
49 | # FIXME: gdb does not yet recognize the GNU extension 'q' suffix for __float128 constants. | |
50 | gdb_test "print ld=-1.375l" ".* = -1\\.375.*" "Try to change ld to -1.375 with 'print ld=-1.375l'" | |
51 | gdb_test "print f128=-2.375l" ".* = -2\\.375.*" "Try to change f128 to -2.375 with 'print f128=-2.375l'" | |
52 | ||
53 | # Test that gdb could handle the above correctly with "set var" command. | |
54 | set test "set variable ld=10.375l" | |
55 | gdb_test_multiple "set var ld=10.375l" "$test" { | |
56 | -re "$gdb_prompt $" { | |
57 | pass "$test" | |
58 | } | |
59 | -re "Invalid number.*$gdb_prompt $" { | |
60 | fail "$test (do not recognize 10.375l)" | |
61 | } | |
62 | } | |
63 | ||
64 | set test "set variable f128=20.375l" | |
65 | gdb_test_multiple "set var f128=20.375l" "$test" { | |
66 | -re "$gdb_prompt $" { | |
67 | pass "$test" | |
68 | } | |
69 | -re "Invalid number.*$gdb_prompt $" { | |
70 | fail "$test (do not recognize 20.375l)" | |
71 | } | |
72 | } | |
73 | ||
74 | gdb_test "print ld" ".* = 10\\.375.*" "The value of ld is changed to 10.375" | |
75 | gdb_test "print f128" ".* = 20\\.375.*" "The value of f128 is changed to 20.375" | |
76 |