RE: [RFA] Handle BINOP_INTDIV in valarith.c

Pierre Muller
2008-01-21T15:04:54Z

I would like to have some feedback from the other languages that
seem to also use BINOP_INTDIV.

Furthermore, my patch is incomplete,
I forgot the eval.c part that is required:

I send here a minimal patch to
allow to get a 'print 13 div 3' to return '4'

Does this patch work for fortran, ada, modula-2?
I suspect that the type checking is not appropriate for
most of these languages:
Boolean types are not considered as ordinals
in pascal, and probably also not in the languages
cited above.
For pascal, 'print 13 div true'
as well as print 12 + true'
should not be allowed, but it is now...

Is this OK?

ChangeLog entry:

2008-01-21 Pierre Muller <muller@ics.u-strasbg.fr>

* eval.c (evaluate_subexp_standard): Support
BINOP_INTDIV opcode.

Index: gdb/eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.77
diff -u -p -r1.77 eval.c
--- gdb/eval.c 18 Jan 2008 17:07:39 -0000 1.77
+++ gdb/eval.c 21 Jan 2008 14:55:45 -0000
@@ -1496,6 +1496,7 @@ evaluate_subexp_standard (struct type *e
case BINOP_EXP:
case BINOP_MUL:
case BINOP_DIV:
+ case BINOP_INTDIV:
case BINOP_REM:
case BINOP_MOD:
case BINOP_LSH:
@@ -1510,7 +1511,8 @@ evaluate_subexp_standard (struct type *e
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, op, OP_NULL, noside);
else if (noside == EVAL_AVOID_SIDE_EFFECTS
- && (op == BINOP_DIV || op == BINOP_REM || op == BINOP_MOD))
+ && (op == BINOP_DIV || op == BINOP_REM || op == BINOP_MOD
+ || op == BINOP_INTDIV))
return value_zero (value_type (arg1), not_lval);
else
return value_binop (arg1, arg2, op);