This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Convert arguments and results for calls to __gnat_mulv64

This is a follow-up to
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  <>

	* gcc-interface/trans.c (build_binary_op_trapv): Convert arguments
	and result for call to __gnat_mulv64.

2008-11-07  Geert Bosch  <>

	* 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);
       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);

   type T is new LONG_INTEGER range -1..10;
   for T'size use 8;

   package P is new G (T);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]