[Ada] Error adding/subtracting pointer value to/from integral.
authorJoel Brobecker <brobecker@adacore.com>
Thu, 9 Oct 2014 16:37:17 +0000 (12:37 -0400)
committerJoel Brobecker <brobecker@adacore.com>
Tue, 14 Oct 2014 21:05:11 +0000 (14:05 -0700)
commitc40cc657bcc930b83ec42e071fe419073bd199f5
tree5bbf82ebaeae8c4787a1ffa35b2011cacaa07dd2
parent2abf49e11e603ecc002fa27704a978733c601386
[Ada] Error adding/subtracting pointer value to/from integral.

When trying to evaluate an expression which adds a pointer and
an integral, the evaluation succeeds if the pointer is on
the left handside of the operator, but not when it is on the right
handside:

    (gdb) p something'address + 0
    $1 = (system.address) 0x613418 <pck.something>
    (gdb) p 0 + something'address
    Argument to arithmetic operation not a number or boolean.

Same issue when doing subtractions:

    (gdb) p something'address - 0
    $2 = (system.address) 0x613418 <pck.something>
    (gdb) p 0 - something'address
    Argument to arithmetic operation not a number or boolean.

This patch enhances the Ada expression evaluator to handle
these two situations.

gdb/ChangeLog:

        * ada-lang.c (ada_evaluate_subexp) <BINOP_ADD>: Add handling
        of the case where the second operand is a pointer.
        <BINOP_SUB>: Likewise.

gdb/testsuite/ChangeLog:

        * gdb.ada/addr_arith: New testcase.

Tested on x86_64-linux.
gdb/ChangeLog
gdb/ada-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/addr_arith.exp [new file with mode: 0644]
gdb/testsuite/gdb.ada/addr_arith/foo_na07_019.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/addr_arith/pck.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/addr_arith/pck.ads [new file with mode: 0644]
This page took 0.025845 seconds and 4 git commands to generate.