aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-02-05 10:56:39 +0100
committerTom de Vries <tdevries@suse.de>2021-02-05 10:56:39 +0100
commitae7104966177c7bcb7bef9e1445489d9d2f97f06 (patch)
tree0db06bfbce6489d5145e0433da37b037cf15f451 /gdb/testsuite
parentd3b54e63f4866551953a03f512049741b0e776c4 (diff)
downloadbinutils-ae7104966177c7bcb7bef9e1445489d9d2f97f06.zip
binutils-ae7104966177c7bcb7bef9e1445489d9d2f97f06.tar.gz
binutils-ae7104966177c7bcb7bef9e1445489d9d2f97f06.tar.bz2
[gdb/exp] Fix assert when adding ptr to imaginary unit
I'm running into this assertion failure: ... $ gdb -batch -ex "p (void *)0 - 5i" gdbtypes.c:3430: internal-error: \ type* init_complex_type(const char*, type*): Assertion \ `target_type->code () == TYPE_CODE_INT \ || target_type->code () == TYPE_CODE_FLT' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. ... This is a regression since commit c34e8714662 "Implement complex arithmetic". Before that commit we had: ... (gdb) p (void *)0 - 5i Argument to arithmetic operation not a number or boolean. ... Fix this in complex_binop by throwing an error, such that we have: ... (gdb) print (void *)0 - 5i Argument to complex arithmetic operation not supported. ... Tested on x86_64-linux. gdb/ChangeLog: 2021-02-05 Tom de Vries <tdevries@suse.de> PR exp/27265 * valarith.c (complex_binop): Throw an error if complex type can't be created. gdb/testsuite/ChangeLog: 2021-02-05 Tom de Vries <tdevries@suse.de> PR exp/27265 * gdb.base/complex-parts.exp: Add tests.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/complex-parts.exp11
2 files changed, 16 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 01539a6..9c24a49 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2021-02-05 Tom de Vries <tdevries@suse.de>
+ PR exp/27265
+ * gdb.base/complex-parts.exp: Add tests.
+
+2021-02-05 Tom de Vries <tdevries@suse.de>
+
PR symtab/27307
* gdb.dwarf2/clang-debug-names.exp: Check file command warnings.
diff --git a/gdb/testsuite/gdb.base/complex-parts.exp b/gdb/testsuite/gdb.base/complex-parts.exp
index 3677c05..6385752 100644
--- a/gdb/testsuite/gdb.base/complex-parts.exp
+++ b/gdb/testsuite/gdb.base/complex-parts.exp
@@ -103,3 +103,14 @@ gdb_test "print (_Complex int) 4" " = 4 \\+ 0i"
gdb_test "print (_Complex float) 4.5" " = 4.5 \\+ 0i"
gdb_test "ptype __complex__ short" " = _Complex short"
gdb_test "print (_Complex int) (23.75 + 8.88i)" " = 23 \\+ 8i"
+
+set re_reject_arg "Argument to complex arithmetic operation not supported\\."
+gdb_test "print (void *)0 + 5i" $re_reject_arg
+gdb_test "print (_Decimal32)0 + 5i" $re_reject_arg
+
+# Set language to c++. Avoid warning by not having current frame.
+clean_restart
+gdb_test_no_output "set language c++"
+
+# C++ type tests.
+gdb_test "print (bool)1 + 1i" " = 1 \\+ 1i"