OSDN Git Service

2010-06-17 Robert Dewar <dewar@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Jun 2010 15:58:10 +0000 (15:58 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Jun 2010 15:58:10 +0000 (15:58 +0000)
* 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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160930 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/einfo.adb
gcc/ada/einfo.ads
gcc/ada/exp_intr.adb
gcc/ada/sem_intr.adb

index 70105c9..275f160 100644 (file)
@@ -1,5 +1,14 @@
 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).
 
 2010-06-17  Robert Dewar  <dewar@adacore.com>
index da4ed38..5a6e8dd 100644 (file)
@@ -5367,7 +5367,8 @@ package body Einfo is
 
    function Known_Static_Esize                    (E : Entity_Id) return B is
    begin
-      return Uint12 (E) > Uint_0;
+      return Uint12 (E) > Uint_0
+        and then not Is_Generic_Type (E);
    end Known_Static_Esize;
 
    function Known_Static_Normalized_First_Bit     (E : Entity_Id) return B is
@@ -5390,9 +5391,10 @@ package body Einfo is
 
    function Known_Static_RM_Size                  (E : Entity_Id) return B is
    begin
-      return Uint13 (E) > Uint_0
-        or else Is_Discrete_Type (E)
-        or else Is_Fixed_Point_Type (E);
+      return (Uint13 (E) > Uint_0
+                or else Is_Discrete_Type (E)
+                or else Is_Fixed_Point_Type (E))
+        and then not Is_Generic_Type (E);
    end Known_Static_RM_Size;
 
    function Unknown_Alignment                     (E : Entity_Id) return B is
index 99c7141..12a770f 100644 (file)
@@ -6188,6 +6188,13 @@ package Einfo is
    --  value is always known static for discrete types (and no other types can
    --  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_Component_Bit_Offset            (E : Entity_Id) return B;
    function Known_Component_Size                  (E : Entity_Id) return B;
index 95a063c..09242c2 100644 (file)
@@ -122,14 +122,12 @@ package body Exp_Intr is
       TR  : constant Entity_Id := Etype (N);
       T3  : Entity_Id;
       Res : Node_Id;
-      Siz : Uint;
+
+      Siz : constant Uint := UI_Max (Esize (T1), Esize (T2));
+      --  Maximum of operand sizes
 
    begin
-      if Esize (T1) > Esize (T2) then
-         Siz := Esize (T1);
-      else
-         Siz := Esize (T2);
-      end if;
+      --  Use Unsigned_32 for sizes of 32 or below, else Unsigned_64
 
       if Siz > 32 then
          T3 := RTE (RE_Unsigned_64);
@@ -137,14 +135,21 @@ package body Exp_Intr is
          T3 := RTE (RE_Unsigned_32);
       end if;
 
+      --  Copy operator node, and reset type and entity fields, for
+      --  subsequent reanalysis.
+
       Res := New_Copy (N);
       Set_Etype (Res, Empty);
       Set_Entity (Res, Empty);
 
+      --  Convert operands to large enough intermediate type
+
       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,
-         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));
       Analyze_And_Resolve (N, TR);
index 63cecbd..add170f 100644 (file)
@@ -285,7 +285,7 @@ package body Sem_Intr is
          return;
       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);
       end if;
    end Check_Intrinsic_Operator;