aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp3
-rw-r--r--gdb/valarith.c2
4 files changed, 13 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e6c572d..4ac0acc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-14 Tom Tromey <tromey@adacore.com>
+
+ * valarith.c (fixed_point_binop): Call error on division by zero.
+
2020-12-13 Tom Tromey <tom@tromey.com>
* gdbtypes.c (safe_parse_type): Make argument const.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c33f0b2..dba9292 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-14 Tom Tromey <tromey@adacore.com>
+
+ * gdb.dwarf2/dw2-fixed-point.exp: Add test for division by zero.
+
2020-12-13 Tom de Vries <tdevries@suse.de>
PR testsuite/26953
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp b/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp
index 67d1d34..2c859d1 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp
@@ -164,6 +164,9 @@ gdb_test "print pck.fp3_var * 1" \
gdb_test "print pck.fp3_var / pck.fp3_var" \
" = 1"
+gdb_test "print pck.fp3_var / 0" \
+ "Division by zero"
+
gdb_test "print pck.fp1_range_var - 0.5" \
" = 0.5"
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 37988f1..6854d9b 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -965,6 +965,8 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
break;
case BINOP_DIV:
+ if (mpq_sgn (v2.val) == 0)
+ error (_("Division by zero"));
mpq_div (res.val, v1.val, v2.val);
val = fixed_point_to_value (res);
break;