]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2004-2024 Free Software Foundation, Inc. |
fb6e1814 JG |
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 |
fb6e1814 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
fb6e1814 JG |
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 | # |
fb6e1814 | 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/>. |
fb6e1814 | 15 | |
fb6e1814 JG |
16 | load_lib "ada.exp" |
17 | ||
74dcf082 | 18 | require allow_ada_tests |
ec3c07fc | 19 | |
8223e12c | 20 | standard_ada_testfile fixed_points |
fb6e1814 | 21 | |
86ef42bd TT |
22 | foreach_with_prefix scenario {all minimal} { |
23 | set flags [list debug additional_flags=-fgnat-encodings=$scenario] | |
5ae3df22 | 24 | if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { |
86ef42bd TT |
25 | return -1 |
26 | } | |
c31af87b | 27 | |
5ae3df22 | 28 | clean_restart ${testfile}-${scenario} |
fb6e1814 | 29 | |
86ef42bd TT |
30 | set bp_location [gdb_get_line_number "Set breakpoint here" ${testdir}/fixed_points.adb] |
31 | runto "fixed_points.adb:$bp_location" | |
fb6e1814 | 32 | |
86ef42bd | 33 | # Fixed point subtypes: |
c31af87b | 34 | |
86ef42bd TT |
35 | gdb_test "print base_object" \ |
36 | "= -50" \ | |
37 | "p on a fixed point type" | |
c31af87b | 38 | |
86ef42bd TT |
39 | gdb_test "print subtype_object" \ |
40 | "= -50" \ | |
41 | "p on a subtype fixed point type" | |
c31af87b | 42 | |
86ef42bd TT |
43 | gdb_test "print new_type_object" \ |
44 | "= -50" \ | |
45 | "p on a new fixed point type" | |
09584414 | 46 | |
86ef42bd | 47 | # Overprecise delta: |
09584414 | 48 | |
86ef42bd TT |
49 | gdb_test "print Overprecise_Object" \ |
50 | "= 0.13579135791" | |
09584414 | 51 | |
bbcdf9ab TT |
52 | gdb_test "ptype Overprecise_Object" \ |
53 | "type = <2-byte fixed point \\(small = 135791357913579/1000000000000000\\)>" | |
09584414 | 54 | |
86ef42bd TT |
55 | # FP*_Var... |
56 | ||
57 | gdb_test "print fp1_var" \ | |
58 | " = 0.25" | |
59 | ||
bbcdf9ab | 60 | gdb_test "ptype fp1_var" "type = <1-byte fixed point \\(small = 1/16\\)>" |
0c9150e4 | 61 | |
86ef42bd TT |
62 | gdb_test "print fp2_var" \ |
63 | " = -0.01" | |
64 | ||
bbcdf9ab | 65 | gdb_test "ptype fp2_var" "type = <8-byte fixed point \\(small = 1/100\\)>" |
86ef42bd TT |
66 | |
67 | gdb_test "print fp3_var" \ | |
68 | " = 0.1" | |
69 | ||
bbcdf9ab TT |
70 | gdb_test "ptype fp3_var" "type = <1-byte fixed point \\(small = 1/30\\)>" |
71 | ||
72 | gdb_test "print fp2_var + 0" \ | |
73 | " = -0.01" | |
74 | gdb_test "print 0 + fp2_var" \ | |
75 | " = -0.01" | |
76 | gdb_test "print fp2_var - 0" \ | |
77 | " = -0.01" | |
78 | ||
6813ceb0 TT |
79 | gdb_test "print + fp2_var" \ |
80 | " = -0.01" | |
81 | gdb_test "print - fp2_var" \ | |
82 | " = 0.01" | |
83 | ||
bbcdf9ab TT |
84 | set fp4 "= 2e-07" |
85 | gdb_test "print fp4_var" $fp4 | |
86 | gdb_test "print fp4_var * 1" $fp4 | |
87 | gdb_test "print 1 * fp4_var" $fp4 | |
88 | gdb_test "print fp4_var / 1" $fp4 | |
b49180ac | 89 | |
bbcdf9ab TT |
90 | # This only started working in GCC 11. |
91 | if {$scenario == "minimal" && [test_compiler_info {gcc-11-*}]} { | |
92 | gdb_test "print fp5_var" " = 3e-19" | |
b49180ac | 93 | } |
fe34aba0 | 94 | |
86bb2d76 TT |
95 | # This failed before GCC 10. |
96 | if {$scenario == "all" && [test_compiler_info {gcc-10-*}]} { | |
97 | gdb_test "p Float(Another_Fixed) = Float(Another_Delta * 5)" "true" \ | |
98 | "value of another_fixed" | |
99 | } | |
0c9150e4 | 100 | } |