Allow pointer arithmetic with integer references
authorHannes Domani <ssbssa@yahoo.de>
Tue, 31 Mar 2020 12:49:06 +0000 (14:49 +0200)
committerHannes Domani <ssbssa@yahoo.de>
Wed, 1 Apr 2020 17:15:03 +0000 (19:15 +0200)
commit60e22c1eacb0df32aeeeb78c53cfd46c53a3770f
treee9870fa9aee3159d44e48cffce61f0d85abf8318
parent77bf7b5317195e092a9f18fef993c412e2e05f53
Allow pointer arithmetic with integer references

Considering these variables:
int i = 3;
int &iref = i;

It's not possible to do any pointer arithmetic with iref:
(gdb) p &i+iref
Argument to arithmetic operation not a number or boolean.

So this adds checks for references to integers in pointer arithmetic.

gdb/ChangeLog:

2020-04-01  Hannes Domani  <ssbssa@yahoo.de>

PR gdb/24789
* eval.c (is_integral_or_integral_reference): New function.
(evaluate_subexp_standard): Allow integer references in
pointer arithmetic.

gdb/testsuite/ChangeLog:

2020-04-01  Hannes Domani  <ssbssa@yahoo.de>

PR gdb/24789
* gdb.cp/misc.cc: Add integer reference variable.
* gdb.cp/misc.exp: Add test.
gdb/ChangeLog
gdb/eval.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/misc.cc
gdb/testsuite/gdb.cp/misc.exp