This is the mail archive of the gcc-patches@gcc.gnu.org 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] Integer promotion for unary operators


This change fixes and extends the circuitry responsible for promotion of
operands to Integer when a conversion to Integer of an arithmetic operation
involving shorter integer types is encountered. (This early conversion helps
avoiding some overflow cases). After this change, the unary minus and
absolute value operators are included in this processing.

The following compilation must produce the displayed expanded code:

$ gcc -c -gnatG proc.adb
Source recreated from tree for Proc (body)
------------------------------------------


procedure proc (x : short_integer; y : short_integer) is
   z : integer;
begin
   z := integer(integer(x) + integer(y));
   z := integer(-integer(x));
   z := integer(abs integer(x));
   return;
end proc;

procedure Proc (X, Y : Short_Integer) is
   Z : Integer;
begin
   Z := Integer (X + Y);
   Z := Integer (-X);
   Z := Integer (abs X);
end Proc;

Tested on x86_64-pc-linux-gnu, committed on trunk

2009-10-28  Thomas Quinot  <quinot@adacore.com>

	* exp_ch4.adb (Expand_N_Type_Conversion): Perform Integer promotion for
	the operand of the unary minus and ABS operators.

Attachment: difs
Description: Text document


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