This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [fortran, patch] Fix pow op.
- From: Feng Wang <wf_cs at yahoo dot com>
- To: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 16 Aug 2005 21:21:33 +0800 (CST)
- Subject: Re: [fortran, patch] Fix pow op.
The committed is enclosed. This bug was found and fixed by Chun Huang, another
member of our group. I credit this to her.
--- Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
> On Thu, Aug 04, 2005 at 12:05:10PM +0800, Feng Wang wrote:
> > This patch fixed pow operation. We should evaluate the first operator.
> > gfc_conv_expr_val (&lse, expr->value.op.op1);
> > + lse.expr = gfc_evaluate_now (lse.expr, &lse.pre);
> > gfc_add_block_to_block (&se->pre, &lse.pre);
> >
> > gfc_init_se (&rse, se);
>
> This is ok for both mainline and 4.0. Please, include a
> ChangeLog entry with your patches.
>
Best Regards,
Feng Wang
--
Creative Compiler Research Group,
National University of Defense Technology, China.
__________________________________
Meet your soulmate!
Yahoo! Asia presents Meetic - where millions of singles gather
http://asia.yahoo.com/meetic
Index: fortran/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/ChangeLog,v
retrieving revision 1.524
diff -c -3 -p -r1.524 ChangeLog
*** fortran/ChangeLog 14 Aug 2005 21:45:03 -0000 1.524
--- fortran/ChangeLog 16 Aug 2005 12:55:06 -0000
***************
*** 1,3 ****
--- 1,8 ----
+ 2004-08-16 Huang Chun <chunhuang73@hotmail.com>
+
+ * trans-expr.c (gfc_conv_power_op): Evaluate the expression before
+ expand.
+
2005-08-14 Asher Langton <langton2@llnl.gov>
* parse.c (match): Enclosed macro in do...while(0) and braces.
Index: fortran/trans-expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-expr.c,v
retrieving revision 1.56
diff -c -3 -p -r1.56 trans-expr.c
*** fortran/trans-expr.c 6 Aug 2005 12:56:18 -0000 1.56
--- fortran/trans-expr.c 16 Aug 2005 12:55:09 -0000
*************** gfc_conv_power_op (gfc_se * se, gfc_expr
*** 654,659 ****
--- 654,660 ----
gfc_init_se (&lse, se);
gfc_conv_expr_val (&lse, expr->value.op.op1);
+ lse.expr = gfc_evaluate_now (lse.expr, &lse.pre);
gfc_add_block_to_block (&se->pre, &lse.pre);
gfc_init_se (&rse, se);
Index: testsuite/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/ChangeLog,v
retrieving revision 1.5926
diff -c -3 -p -r1.5926 ChangeLog
*** testsuite/ChangeLog 16 Aug 2005 08:37:58 -0000 1.5926
--- testsuite/ChangeLog 16 Aug 2005 12:52:07 -0000
***************
*** 1,3 ****
--- 1,7 ----
+ 2005-08-16 Feng Wang <fengwang@nudt.edu.cn>
+
+ * gfortran.dg/power.f90: New test.
+
2005-08-16 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/23299
Index: testsuite/gfortran.dg/power.f90
===================================================================
RCS file: testsuite/gfortran.dg/power.f90
diff -N testsuite/gfortran.dg/power.f90
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gfortran.dg/power.f90 16 Aug 2005 12:52:08 -0000
***************
*** 0 ****
--- 1,11 ----
+ ! { dg-do run }
+ integer i
+ i = 0
+ if ( a (i) ** 5 .ne. 1) call abort ()
+ contains
+ function a (i)
+ integer a, i
+ i = i + 1
+ a = i
+ end function
+ end