Commit 92252980 by Robert Dewar Committed by Arnaud Charlet

exp_intr.adb: Minor code reorganization (use UI_Max)

2010-06-17  Robert Dewar  <dewar@adacore.com>

	* exp_intr.adb: Minor code reorganization (use UI_Max)
	* sem_intr.adb: use underlying type to check legality.
	* einfo.adb (Known_Static_Esize): False for generic types
	(Known_Static_RM_Size): False for generic types
	* einfo.ads (Known_Static_Esize): False for generic types
	(Known_Static_RM_Size): False for generic types

From-SVN: r160930
parent 955871d3
2010-06-17 Robert Dewar <dewar@adacore.com> 2010-06-17 Robert Dewar <dewar@adacore.com>
* exp_intr.adb: Minor code reorganization (use UI_Max)
* sem_intr.adb: use underlying type to check legality.
* einfo.adb (Known_Static_Esize): False for generic types
(Known_Static_RM_Size): False for generic types
* einfo.ads (Known_Static_Esize): False for generic types
(Known_Static_RM_Size): False for generic types
2010-06-17 Robert Dewar <dewar@adacore.com>
* exp_ch4.ads: Minor code reorganization (specs in alpha order). * exp_ch4.ads: Minor code reorganization (specs in alpha order).
2010-06-17 Robert Dewar <dewar@adacore.com> 2010-06-17 Robert Dewar <dewar@adacore.com>
......
...@@ -5367,7 +5367,8 @@ package body Einfo is ...@@ -5367,7 +5367,8 @@ package body Einfo is
function Known_Static_Esize (E : Entity_Id) return B is function Known_Static_Esize (E : Entity_Id) return B is
begin begin
return Uint12 (E) > Uint_0; return Uint12 (E) > Uint_0
and then not Is_Generic_Type (E);
end Known_Static_Esize; end Known_Static_Esize;
function Known_Static_Normalized_First_Bit (E : Entity_Id) return B is function Known_Static_Normalized_First_Bit (E : Entity_Id) return B is
...@@ -5390,9 +5391,10 @@ package body Einfo is ...@@ -5390,9 +5391,10 @@ package body Einfo is
function Known_Static_RM_Size (E : Entity_Id) return B is function Known_Static_RM_Size (E : Entity_Id) return B is
begin begin
return Uint13 (E) > Uint_0 return (Uint13 (E) > Uint_0
or else Is_Discrete_Type (E) or else Is_Discrete_Type (E)
or else Is_Fixed_Point_Type (E); or else Is_Fixed_Point_Type (E))
and then not Is_Generic_Type (E);
end Known_Static_RM_Size; end Known_Static_RM_Size;
function Unknown_Alignment (E : Entity_Id) return B is function Unknown_Alignment (E : Entity_Id) return B is
......
...@@ -6188,6 +6188,13 @@ package Einfo is ...@@ -6188,6 +6188,13 @@ package Einfo is
-- value is always known static for discrete types (and no other types can -- value is always known static for discrete types (and no other types can
-- have an RM_Size value of zero). -- have an RM_Size value of zero).
-- In two cases, Known_Static_Esize and Known_Static_RM_Size, there is one
-- more consideration, which is that we always return false for generic
-- types. Within a template, the size can look known, because of the fake
-- size values we put in template types, but they are not really known and
-- anyone testing if they are known within the template should get False as
-- a result to prevent incorrect assumptions.
function Known_Alignment (E : Entity_Id) return B; function Known_Alignment (E : Entity_Id) return B;
function Known_Component_Bit_Offset (E : Entity_Id) return B; function Known_Component_Bit_Offset (E : Entity_Id) return B;
function Known_Component_Size (E : Entity_Id) return B; function Known_Component_Size (E : Entity_Id) return B;
......
...@@ -122,14 +122,12 @@ package body Exp_Intr is ...@@ -122,14 +122,12 @@ package body Exp_Intr is
TR : constant Entity_Id := Etype (N); TR : constant Entity_Id := Etype (N);
T3 : Entity_Id; T3 : Entity_Id;
Res : Node_Id; Res : Node_Id;
Siz : Uint;
Siz : constant Uint := UI_Max (Esize (T1), Esize (T2));
-- Maximum of operand sizes
begin begin
if Esize (T1) > Esize (T2) then -- Use Unsigned_32 for sizes of 32 or below, else Unsigned_64
Siz := Esize (T1);
else
Siz := Esize (T2);
end if;
if Siz > 32 then if Siz > 32 then
T3 := RTE (RE_Unsigned_64); T3 := RTE (RE_Unsigned_64);
...@@ -137,14 +135,21 @@ package body Exp_Intr is ...@@ -137,14 +135,21 @@ package body Exp_Intr is
T3 := RTE (RE_Unsigned_32); T3 := RTE (RE_Unsigned_32);
end if; end if;
-- Copy operator node, and reset type and entity fields, for
-- subsequent reanalysis.
Res := New_Copy (N); Res := New_Copy (N);
Set_Etype (Res, Empty); Set_Etype (Res, Empty);
Set_Entity (Res, Empty); Set_Entity (Res, Empty);
-- Convert operands to large enough intermediate type
Set_Left_Opnd (Res, Set_Left_Opnd (Res,
Unchecked_Convert_To (T3, Relocate_Node (Left_Opnd (N)))); Unchecked_Convert_To (T3, Relocate_Node (Left_Opnd (N))));
Set_Right_Opnd (Res, Set_Right_Opnd (Res,
Unchecked_Convert_To (T3, Relocate_Node (Right_Opnd (N)))); Unchecked_Convert_To (T3, Relocate_Node (Right_Opnd (N))));
-- Analyze and resolve result formed by conversion to target type
Rewrite (N, Unchecked_Convert_To (TR, Res)); Rewrite (N, Unchecked_Convert_To (TR, Res));
Analyze_And_Resolve (N, TR); Analyze_And_Resolve (N, TR);
......
...@@ -285,7 +285,7 @@ package body Sem_Intr is ...@@ -285,7 +285,7 @@ package body Sem_Intr is
return; return;
end if; end if;
if not Is_Numeric_Type (T1) then if not Is_Numeric_Type (Underlying_Type (T1)) then
Errint ("intrinsic operator can only apply to numeric types", E, N); Errint ("intrinsic operator can only apply to numeric types", E, N);
end if; end if;
end Check_Intrinsic_Operator; end Check_Intrinsic_Operator;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment