This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [fortran, patch] Fix PR 14377 - simplifying minmax bug.
- From: Feng Wang <wf_cs at yahoo dot com>
- To: Paul Brook <paul at codesourcery dot com>, gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Cc: bdavis9659 at comcast dot net
- Date: Wed, 10 Mar 2004 09:53:37 +0800 (CST)
- Subject: Re: [fortran, patch] Fix PR 14377 - simplifying minmax bug.
Hmmm, The type isn't still correct. The expression and the function's type may
both be BT_UNKNOWN, because we simplify the intrinsic function before resolve
it.
I think this patch can fix it. And the test case patch is also attached.
Feng Wang
The testsuits ChangeLog.tree-ssa:
2004-03-10 Feng Wang <fengwang@nudt.edu.cn>
* gfortran.fortran-torture/execute/intrinsic_minmax.f90: Add simplify
test.
The fortran ChangeLog:
2004-03-03 Feng Wang <fengwang@nudt.edu.cn>
PR fortran/14377
* simplify.c (simplify_min_max): Convert the type of the result.
--- Paul Brook <paul@codesourcery.com> 的正文:> > ChangeLog entry:
> > 2004-03-03 Feng Wang <fengwang@nudt.edu.cn>
> >
> > PR fortran/14377
> > * simplify.c (simplify_min_max): Convert the type of the result.
>
> Ok.
>
> Paul
_________________________________________________________
Do You Yahoo!?
完全免费的雅虎电邮,马上注册获赠额外60兆网络存储空间
http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.mail.yahoo.com
*** fortran/simplify.c Wed Mar 3 16:30:59 2004
--- gcc/gcc/fortran/simplify.c Wed Mar 10 09:23:10 2004
*************** static gfc_expr *
*** 2150,2158 ****
--- 2150,2160 ----
simplify_min_max (gfc_expr * expr, int sign)
{
gfc_actual_arglist *arg, *last, *extremum;
+ gfc_intrinsic_sym * specific;
last = NULL;
extremum = NULL;
+ specific = expr->value.function.isym;
arg = expr->value.function.actual;
*************** simplify_min_max (gfc_expr * expr, int s
*** 2203,2208 ****
--- 2205,2219 ----
if (expr->value.function.actual->next != NULL)
return NULL;
+ /* Convert to the correct type and kind. */
+ if (expr->ts.type != BT_UNKNOWN)
+ return gfc_convert_constant (expr->value.function.actual->expr,
+ expr->ts.type, expr->ts.kind);
+
+ if (specific->ts.type != BT_UNKNOWN)
+ return gfc_convert_constant (expr->value.function.actual->expr,
+ specific->ts.type, specific->ts.kind);
+
return gfc_copy_expr (expr->value.function.actual->expr);
}
*** /home/wf/0303/gcc/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_minmax.f90 Sat Jan 10 13:09:19 2004
--- intrinsic_minmax.f90 Wed Mar 10 09:08:04 2004
*************** program intrinsic_minmax
*** 26,30 ****
--- 26,37 ----
if (max (4d0, r) .ne. 4d0) call abort
if (amax0 (i, j) .ne. 1.0) call abort
if (min1 (r, s) .ne. -2) call abort
+
+ ! Test simplify.
+ if (min (1, -2, 3, 4) .ne. -2) call abort
+ if (max (1, -2, 3, 4) .ne. 4) call abort
+ if (amax0 (1, -2) .ne. 1.0) call abort
+ if (min1 (1., -2.) .ne. -2) call abort
+
end program