This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Replace build_int_2
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Mark Mitchell <mark at codesourcery dot com>
- Date: Mon, 16 Aug 2004 17:41:45 +0100
- Subject: Re: Replace build_int_2
- Organization: Codesourcery LLC
- References: <4114E641.4020805@codesourcery.com> <jeacwvcgsy.fsf@sykes.suse.de>
Andreas Schwab wrote:
Nathan Sidwell <nathan@codesourcery.com> writes:
* ada/cuintp.c (UI_To_gnu): Likewise.
This is wrong. comp_type can be a floating point type here (see the call
under case N_Real_Literal in ada/trans.c:gnat_to_gnu).
I have installed this obvious patch, which restores the convert calls.
built on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2004-08-16 Nathan Sidwell <nathan@codesourcery.com>
* cuintp.c (UI_To_gnu): Be more conservative with build_int_cst
call.s
* trans.c (Exception_Handler_to_gnu_sjlj): Likewise.
(gnat_to_gnu): Likewise.
Index: ada/cuintp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/cuintp.c,v
retrieving revision 1.9
diff -c -3 -p -r1.9 cuintp.c
*** ada/cuintp.c 15 Aug 2004 15:45:05 -0000 1.9
--- ada/cuintp.c 16 Aug 2004 14:34:03 -0000
*************** UI_To_gnu (Uint Input, tree type)
*** 76,101 ****
tree comp_type
= (TYPE_PRECISION (type) >= TYPE_PRECISION (integer_type_node)
? type : integer_type_node);
! tree gnu_base = build_int_cst (comp_type, Base, 0);
if (Length <= 0)
abort ();
! gnu_ret = build_int_cst (comp_type, First, First < 0 ? -1 : 0);
if (First < 0)
for (Idx++, Length--; Length; Idx++, Length--)
gnu_ret = fold (build (MINUS_EXPR, comp_type,
fold (build (MULT_EXPR, comp_type,
gnu_ret, gnu_base)),
! build_int_cst (comp_type,
! Udigits_Ptr[Idx], 0)));
else
for (Idx++, Length--; Length; Idx++, Length--)
gnu_ret = fold (build (PLUS_EXPR, comp_type,
fold (build (MULT_EXPR, comp_type,
gnu_ret, gnu_base)),
! build_int_cst (comp_type,
! Udigits_Ptr[Idx], 0)));
}
gnu_ret = convert (type, gnu_ret);
--- 76,104 ----
tree comp_type
= (TYPE_PRECISION (type) >= TYPE_PRECISION (integer_type_node)
? type : integer_type_node);
! tree gnu_base = convert (comp_type, build_int_cst (NULL_TREE, Base, 0));
if (Length <= 0)
abort ();
! gnu_ret = convert (comp_type, build_int_cst (NULL_TREE,
! First, First < 0 ? -1 : 0));
if (First < 0)
for (Idx++, Length--; Length; Idx++, Length--)
gnu_ret = fold (build (MINUS_EXPR, comp_type,
fold (build (MULT_EXPR, comp_type,
gnu_ret, gnu_base)),
! convert (comp_type,
! build_int_cst (NULL_TREE,
! Udigits_Ptr[Idx], 0))));
else
for (Idx++, Length--; Length; Idx++, Length--)
gnu_ret = fold (build (PLUS_EXPR, comp_type,
fold (build (MULT_EXPR, comp_type,
gnu_ret, gnu_base)),
! convert (comp_type,
! build_int_cst (NULL_TREE,
! Udigits_Ptr[Idx], 0))));
}
gnu_ret = convert (type, gnu_ret);
Index: ada/trans.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/trans.c,v
retrieving revision 1.74
diff -c -3 -p -r1.74 trans.c
*** ada/trans.c 15 Aug 2004 15:45:05 -0000 1.74
--- ada/trans.c 16 Aug 2004 14:34:21 -0000
*************** Exception_Handler_to_gnu_sjlj (Node_Id g
*** 2217,2224 ****
= build_binary_op
(TRUTH_ORIF_EXPR, integer_type_node,
build_binary_op (EQ_EXPR, integer_type_node, gnu_comp,
! build_int_cst (TREE_TYPE (gnu_comp),
! 'V', 0)),
this_choice);
}
}
--- 2217,2225 ----
= build_binary_op
(TRUTH_ORIF_EXPR, integer_type_node,
build_binary_op (EQ_EXPR, integer_type_node, gnu_comp,
! convert (TREE_TYPE (gnu_comp),
! build_int_cst (NULL_TREE,
! 'V', 0))),
this_choice);
}
}
*************** gnat_to_gnu (Node_Id gnat_node)
*** 2504,2511 ****
if (Present (Entity (gnat_node)))
gnu_result = DECL_INITIAL (get_gnu_tree (Entity (gnat_node)));
else
! gnu_result = build_int_cst (gnu_result_type,
! Char_Literal_Value (gnat_node), 0);
break;
case N_Real_Literal:
--- 2505,2513 ----
if (Present (Entity (gnat_node)))
gnu_result = DECL_INITIAL (get_gnu_tree (Entity (gnat_node)));
else
! gnu_result = convert (gnu_result_type,
! build_int_cst (NULL_TREE,
! Char_Literal_Value (gnat_node), 0));
break;
case N_Real_Literal:
*************** gnat_to_gnu (Node_Id gnat_node)
*** 2617,2626 ****
for (i = 0; i < length; i++)
{
gnu_list
! = tree_cons (gnu_idx, build_int_cst
! (TREE_TYPE (gnu_result_type),
! Get_String_Char (gnat_string, i + 1), 0),
! gnu_list);
gnu_idx = int_const_binop (PLUS_EXPR, gnu_idx, integer_one_node,
0);
--- 2619,2631 ----
for (i = 0; i < length; i++)
{
gnu_list
! = tree_cons (gnu_idx,
! convert (TREE_TYPE (gnu_result_type),
! build_int_cst
! (NULL_TREE,
! Get_String_Char (gnat_string, i + 1),
! 0)),
! gnu_list);
gnu_idx = int_const_binop (PLUS_EXPR, gnu_idx, integer_one_node,
0);