This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFC] Add code to support evaluating Fortran exponentiationexpression
On Fri, 17 Jun 2005, Daniel Jacobowitz wrote:
> On Fri, Jun 17, 2005 at 01:22:26PM +0800, Wu Zhou wrote:
> > 2005-06-17 Wu Zhou <woodzltc@cn.ibm.com>
> >
> > * f-exp.y (yyparse): Add code to support exponentiation expression.
> > (yylex): Add code to scan exponentiation operator.
> > * eval.c (evaluate_subexp_standard): Add support for BINOP_EXP.
> > * valarith.c (value_binop): Reset errno to 0 before calling pow
> > to do exponentiation operation.
>
> This will need a testcase, in addition to documentation. Doing those
> separately is fine. The only other problem is that f-exp.y needs a
> copyright year update: the last listed year is 2001, but I see it has
> been modified in 2002, 2003, and 2004. So please add all of those
> years (plus 2005).
OK. I add five tests in gdb.fortran/exprs.exp (patch is included below).
Without the above patch, all the five tests fail; with it, all pass. OK
to commit? Thanks.
2005-06-20 Wu Zhou <woodzltc@cn.ibm.com>
* gdb.fortran/exprs.exp (test_arithmetic_expressions): Add five
tests to evaluate exponentiation expression.
Index: gdb.fortran/exprs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.fortran/exprs.exp,v
retrieving revision 1.3
diff -c -p -r1.3 exprs.exp
*** gdb.fortran/exprs.exp 16 Dec 2002 19:33:53 -0000 1.3
--- gdb.fortran/exprs.exp 20 Jun 2005 03:25:02 -0000
*************** proc test_arithmetic_expressions {} {
*** 250,255 ****
--- 250,263 ----
# Test modulo with various operands
+ # Test exponentiation with various operands
+
+ gdb_test "p 2 ** 3" " = 8" "int powered by int"
+ gdb_test "p 2 ** 2 ** 3" " = 256" "combined exponentiation expression"
+ gdb_test "p (2 ** 2) ** 3" " = 64" "combined exponentiation expression in specified order"
+ gdb_test "p 4 ** 0.5" " = 2" "int powered by real"
+ gdb_test "p 4.0 ** 0.5" " = 2" "real powered by real"
+
}
# Start with a fresh gdb.
Cheers
- Wu Zhou