This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[fortran, patch] Patch for PR/14395 - Fix image part of cmplx's result.
- From: Feng Wang <wf_cs at yahoo dot com>
- To: fortran <fortran at gcc dot gnu dot org>, patch <gcc-patches at gcc dot gnu dot org>
- Cc: bdavis9659 at comcast dot net
- Date: Thu, 4 Mar 2004 18:06:21 +0800 (CST)
- Subject: [fortran, patch] Patch for PR/14395 - Fix image part of cmplx's result.
Hi, Steven, Paul, Bud, etc
This patch fixes a bug in cmplx intrinsic function. If X is a complex, the
image part of cmplx(X) is the same with X.
OK to apply?
Feng Wang
ChangeLog entry:
2004-03-04 Feng Wang <fengwang@nudt.edu.cn>
PR fortran/14395
* trans-intrinsic.c (gfc_conv_intrinsic_cmplx): Fix the image part of
the result.
_________________________________________________________
Do You Yahoo!?
完全免费的雅虎电邮,马上注册获赠额外60兆网络存储空间
http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.mail.yahoo.com
*** fortran/trans-intrinsic.c Wed Mar 3 16:30:59 2004
--- gcc/gcc/fortran/trans-intrinsic.c Thu Mar 4 17:35:35 2004
*************** gfc_conv_intrinsic_abs (gfc_se * se, gfc
*** 737,743 ****
/* Create a complex value from one or two real components. */
static void
! gfc_conv_intrinsic_cmplx (gfc_se * se, gfc_expr * expr, int both)
{
tree arg;
tree real;
--- 737,743 ----
/* Create a complex value from one or two real components. */
static void
! gfc_conv_intrinsic_cmplx (gfc_se * se, gfc_expr * expr, int both, int cmplx)
{
tree arg;
tree real;
*************** gfc_conv_intrinsic_cmplx (gfc_se * se, g
*** 747,755 ****
type = gfc_typenode_for_spec (&expr->ts);
arg = gfc_conv_intrinsic_function_args (se, expr);
real = convert (TREE_TYPE (type), TREE_VALUE (arg));
- arg = TREE_CHAIN (arg);
if (both)
! imag = convert (TREE_TYPE (type), TREE_VALUE (arg));
else
imag = build_real_from_int_cst (TREE_TYPE (type), integer_zero_node);
--- 747,760 ----
type = gfc_typenode_for_spec (&expr->ts);
arg = gfc_conv_intrinsic_function_args (se, expr);
real = convert (TREE_TYPE (type), TREE_VALUE (arg));
if (both)
! imag = convert (TREE_TYPE (type), TREE_VALUE (TREE_CHAIN (arg)));
! else if (cmplx)
! {
! arg = TREE_VALUE (arg);
! imag = build1 (IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg);
! imag = convert (TREE_TYPE (type), imag);
! }
else
imag = build_real_from_int_cst (TREE_TYPE (type), integer_zero_node);
*************** gfc_conv_intrinsic_function (gfc_se * se
*** 2703,2709 ****
break;
case GFC_ISYM_CMPLX:
! gfc_conv_intrinsic_cmplx (se, expr, name[5] == '1');
break;
case GFC_ISYM_CONJG:
--- 2708,2714 ----
break;
case GFC_ISYM_CMPLX:
! gfc_conv_intrinsic_cmplx (se, expr, name[5] == '1', name[9] == 'c');
break;
case GFC_ISYM_CONJG: