1 # Copyright 2004-2024 Free Software Foundation, Inc.
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.
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.
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/>.
18 require allow_ada_tests
20 standard_ada_testfile fixed_points
22 foreach_gnat_encoding scenario flags {all minimal} {
24 if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
28 clean_restart ${testfile}-${scenario}
30 set bp_location [gdb_get_line_number "Set breakpoint here" ${testdir}/fixed_points.adb]
31 runto "fixed_points.adb:$bp_location"
33 # Fixed point subtypes:
35 gdb_test "print base_object" \
37 "p on a fixed point type"
39 gdb_test "print subtype_object" \
41 "p on a subtype fixed point type"
43 gdb_test "print new_type_object" \
45 "p on a new fixed point type"
49 gdb_test "print Overprecise_Object" \
52 gdb_test "ptype Overprecise_Object" \
53 "type = <2-byte fixed point \\(small = 135791357913579/1000000000000000\\)>"
57 gdb_test "print fp1_var" \
60 gdb_test "ptype fp1_var" "type = <1-byte fixed point \\(small = 1/16\\)>"
62 gdb_test "print fp2_var" \
65 gdb_test "ptype fp2_var" "type = <8-byte fixed point \\(small = 1/100\\)>"
67 gdb_test "print fp3_var" \
70 gdb_test "ptype fp3_var" "type = <1-byte fixed point \\(small = 1/30\\)>"
72 gdb_test "print fp2_var + 0" \
74 gdb_test "print 0 + fp2_var" \
76 gdb_test "print fp2_var - 0" \
79 gdb_test "print + fp2_var" \
81 gdb_test "print - fp2_var" \
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
90 # This only started working in GCC 11.
91 if {$scenario == "minimal" && [gnat_version_compare >= 11]} {
92 gdb_test "print fp5_var" " = 3e-19"
95 # This failed before GCC 10.
96 if {$scenario == "all" && [gnat_version_compare >= 10]} {
97 gdb_test "p Float(Another_Fixed) = Float(Another_Delta * 5)" "true" \
98 "value of another_fixed"