This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] Convert arguments and results for calls to __gnat_mulv64
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 7 Nov 2008 10:58:17 +0100
- Subject: [Ada] Convert arguments and results for calls to __gnat_mulv64
This is a follow-up to
http://gcc.gnu.org/ml/gcc-patches/2008-07/msg02416.html
so no code generation change for the time being.
Some subtypes of 64-bit integer types have different representations,
potentially resulting in wrong results without proper type conversions
when calling the __gnat_mulv64 helper routine. This patch adds the
necessary conversions.
Tested on i586-suse-linux, applied on the mainline.
2008-11-07 Geert Bosch <bosch@adacore.com>
* gcc-interface/trans.c (build_binary_op_trapv): Convert arguments
and result for call to __gnat_mulv64.
2008-11-07 Geert Bosch <bosch@adacore.com>
* gnat.dg/test_8bitlong_overflow.adb: New test.
--
Eric Botcazou
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c (revision 141667)
+++ gcc-interface/trans.c (working copy)
@@ -6032,7 +6032,13 @@ build_binary_op_trapv (enum tree_code co
int needed_precision = precision * 2;
if (code == MULT_EXPR && precision == 64)
- return build_call_2_expr (mulv64_decl, lhs, rhs);
+ {
+ tree int_64 = gnat_type_for_size (64, 0);
+
+ return convert (gnu_type, build_call_2_expr (mulv64_decl,
+ convert (int_64, lhs),
+ convert (int_64, rhs)));
+ }
else if (needed_precision <= BITS_PER_WORD
|| (code == MULT_EXPR
-- { dg-do run }
-- { dg-options "-gnato" }
procedure Test_8bitlong_Overflow is
pragma Unsuppress (Overflow_Check);
generic
type T is range <>;
package G is
LO : T := T'first;
ONE : T := T(1);
type A2 is array(T range <>) of T;
subtype SA2 is A2(LO..4*ONE);
ARRAY_AGGR : SA2 := SA2'(others=>LO + 1);
POS_1 : T := T'pos(LO*ONE);
end;
type T is new LONG_INTEGER range -1..10;
for T'size use 8;
package P is new G (T);
begin
null;
end;