OSDN Git Service

* config/mips/mips.c (TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P): Undef.
[pf3gnuchains/gcc-fork.git] / gcc / ada / sem_type.adb
index fad78d4..d35326e 100644 (file)
@@ -732,7 +732,7 @@ package body Sem_Type is
    begin
       --  If either operand missing, then this is an error, but ignore it (and
       --  pretend we have a cover) if errors already detected, since this may
-      --  simply mean we have malformed trees.
+      --  simply mean we have malformed trees or a semantic error upstream.
 
       if No (T1) or else No (T2) then
          if Total_Errors_Detected /= 0 then
@@ -791,7 +791,7 @@ package body Sem_Type is
                      or else Scope (T1) /= Scope (T2));
          end if;
 
-      --  Literals are compatible with types in  a given "class"
+      --  Literals are compatible with types in a given "class"
 
       elsif     (T2 = Universal_Integer and then Is_Integer_Type (T1))
         or else (T2 = Universal_Real    and then Is_Real_Type (T1))
@@ -803,7 +803,8 @@ package body Sem_Type is
       then
          return True;
 
-      --  The context may be class wide
+      --  The context may be class wide, and a class-wide type is
+      --  compatible with any member of the class.
 
       elsif Is_Class_Wide_Type (T1)
         and then Is_Ancestor (Root_Type (T1), T2)
@@ -816,8 +817,8 @@ package body Sem_Type is
       then
          return True;
 
-      --  Ada 2005 (AI-345): A class-wide abstract interface type T1 covers a
-      --  task_type or protected_type implementing T1
+      --  Ada 2005 (AI-345): A class-wide abstract interface type covers a
+      --  task_type or protected_type that implements the interface.
 
       elsif Ada_Version >= Ada_05
         and then Is_Class_Wide_Type (T1)
@@ -884,7 +885,10 @@ package body Sem_Type is
       then
          return True;
 
-      --  Some contexts require a class of types rather than a specific type
+      --  Some contexts require a class of types rather than a specific type.
+      --  For example, conditions require any boolean type, fixed point
+      --  attributes require some real type, etc. The built-in types Any_XXX
+      --  represent these classes.
 
       elsif (T1 = Any_Integer and then Is_Integer_Type (T2))
         or else (T1 = Any_Boolean and then Is_Boolean_Type (T2))
@@ -963,6 +967,8 @@ package body Sem_Type is
       then
          return Covers (Corresponding_Remote_Type (T1), T2);
 
+      --  and conversely.
+
       elsif Is_Record_Type (T2)
         and then (Is_Remote_Call_Interface (T2)
                    or else Is_Remote_Types (T2))
@@ -970,9 +976,30 @@ package body Sem_Type is
       then
          return Covers (Corresponding_Remote_Type (T2), T1);
 
+      --  Synchronized types are represented at run time by their corresponding
+      --  record type. During expansion one is replaced with the other, but
+      --  they are compatible views of the same type.
+
+      elsif Is_Record_Type (T1)
+        and then Is_Concurrent_Type (T2)
+        and then Present (Corresponding_Record_Type (T2))
+      then
+         return Covers (T1, Corresponding_Record_Type (T2));
+
+      elsif Is_Concurrent_Type (T1)
+        and then Present (Corresponding_Record_Type (T1))
+        and then Is_Record_Type (T2)
+      then
+         return Covers (Corresponding_Record_Type (T1), T2);
+
+      --  During analysis, an attribute reference 'Access has a special type
+      --  kind: Access_Attribute_Type, to be replaced eventually with the type
+      --  imposed by context.
+
       elsif Ekind (T2) = E_Access_Attribute_Type
         and then (Ekind (BT1) = E_General_Access_Type
-                    or else Ekind (BT1) = E_Access_Type)
+                    or else
+                  Ekind (BT1) = E_Access_Type)
         and then Covers (Designated_Type (T1), Designated_Type (T2))
       then
          --  If the target type is a RACW type while the source is an access
@@ -984,6 +1011,8 @@ package body Sem_Type is
 
          return True;
 
+      --  Ditto for allocators, which eventually resolve to the context type
+
       elsif Ekind (T2) = E_Allocator_Type
         and then Is_Access_Type (T1)
       then
@@ -1008,7 +1037,7 @@ package body Sem_Type is
       --  A packed array type covers its corresponding non-packed type. This is
       --  not legitimate Ada, but allows the omission of a number of otherwise
       --  useless unchecked conversions, and since this can only arise in
-      --  (known correct) expanded code, no harm is done
+      --  (known correct) expanded code, no harm is done.
 
       elsif Is_Array_Type (T2)
         and then Is_Packed (T2)
@@ -1065,7 +1094,7 @@ package body Sem_Type is
          return True;
 
       --  Ada 2005 (AI-50217): Additional branches to make the shadow entity
-      --  compatible with its real entity.
+      --  obtained through a limited_with compatible with its real entity.
 
       elsif From_With_Type (T1) then
 
@@ -1087,7 +1116,7 @@ package body Sem_Type is
 
          --  If units in the context have Limited_With clauses on each other,
          --  either type might have a limited view. Checks performed elsewhere
-         --  verify that the context type is the non-limited view.
+         --  verify that the context type is the nonlimited view.
 
          if Is_Incomplete_Type (T2) then
             return Covers (T1, Get_Full_View (Non_Limited_View (T2)));
@@ -1111,7 +1140,7 @@ package body Sem_Type is
 
       --  Ada 2005 (AI-423): Coverage of formal anonymous access types
       --  and actual anonymous access types in the context of generic
-      --  instantiation. We have the following situation:
+      --  instantiations. We have the following situation:
 
       --     generic
       --        type Formal is private;
@@ -1133,7 +1162,7 @@ package body Sem_Type is
       then
          return True;
 
-      --  Otherwise it doesn't cover!
+      --  Otherwise, types are not compatible!
 
       else
          return False;
@@ -1147,8 +1176,7 @@ package body Sem_Type is
    function Disambiguate
      (N      : Node_Id;
       I1, I2 : Interp_Index;
-      Typ    : Entity_Id)
-      return   Interp
+      Typ    : Entity_Id) return Interp
    is
       I           : Interp_Index;
       It          : Interp;
@@ -1161,13 +1189,6 @@ package body Sem_Type is
       --  Determine whether one of the candidates is an operation inherited by
       --  a type that is derived from an actual in an instantiation.
 
-      function In_Generic_Actual (Exp : Node_Id) return Boolean;
-      --  Determine whether the expression is part of a generic actual. At
-      --  the time the actual is resolved the scope is already that of the
-      --  instance, but conceptually the resolution of the actual takes place
-      --  in the enclosing context, and no special disambiguation rules should
-      --  be applied.
-
       function Is_Actual_Subprogram (S : Entity_Id) return Boolean;
       --  Determine whether a subprogram is an actual in an enclosing instance.
       --  An overloading between such a subprogram and one declared outside the
@@ -1204,34 +1225,6 @@ package body Sem_Type is
       --  for special handling of expressions with universal operands, see
       --  comments to Has_Abstract_Interpretation below.
 
-      -----------------------
-      -- In_Generic_Actual --
-      -----------------------
-
-      function In_Generic_Actual (Exp : Node_Id) return Boolean is
-         Par : constant Node_Id := Parent (Exp);
-
-      begin
-         if No (Par) then
-            return False;
-
-         elsif Nkind (Par) in N_Declaration then
-            if Nkind (Par) = N_Object_Declaration
-              or else Nkind (Par) = N_Object_Renaming_Declaration
-            then
-               return Present (Corresponding_Generic_Association (Par));
-            else
-               return False;
-            end if;
-
-         elsif Nkind (Par) in N_Statement_Other_Than_Procedure_Call then
-            return False;
-
-         else
-            return In_Generic_Actual (Parent (Par));
-         end if;
-      end In_Generic_Actual;
-
       ---------------------------
       -- Inherited_From_Actual --
       ---------------------------
@@ -1260,7 +1253,7 @@ package body Sem_Type is
          return In_Open_Scopes (Scope (S))
            and then
              (Is_Generic_Instance (Scope (S))
-                or else Is_Wrapper_Package (Scope (S)));
+               or else Is_Wrapper_Package (Scope (S)));
       end Is_Actual_Subprogram;
 
       -------------
@@ -1274,8 +1267,7 @@ package body Sem_Type is
          return T1 = T2
            or else
              (Is_Numeric_Type (T2)
-               and then
-             (T1 = Universal_Real or else T1 = Universal_Integer));
+               and then (T1 = Universal_Real or else T1 = Universal_Integer));
       end Matches;
 
       ------------------------
@@ -1417,9 +1409,8 @@ package body Sem_Type is
                   elsif Present (Act2)
                     and then Nkind (Act2) in N_Op
                     and then Is_Overloaded (Act2)
-                    and then (Nkind (Right_Opnd (Act2)) = N_Integer_Literal
-                                or else
-                              Nkind (Right_Opnd (Act2)) = N_Real_Literal)
+                    and then Nkind_In (Right_Opnd (Act2), N_Integer_Literal,
+                                                          N_Real_Literal)
                     and then Has_Compatible_Type (Act2, Standard_Boolean)
                   then
                      --  The preference rule on the first actual is not
@@ -2116,7 +2107,7 @@ package body Sem_Type is
       end if;
 
       Map_Ptr := Headers (Hash (O_N));
-      while Present (Interp_Map.Table (Map_Ptr).Node) loop
+      while Map_Ptr /= No_Entry loop
          if Interp_Map.Table (Map_Ptr).Node = O_N then
             Int_Ind := Interp_Map.Table (Map_Ptr).Index;
             It := All_Interp.Table (Int_Ind);
@@ -2526,6 +2517,35 @@ package body Sem_Type is
       return Typ;
    end Intersect_Types;
 
+   -----------------------
+   -- In_Generic_Actual --
+   -----------------------
+
+   function In_Generic_Actual (Exp : Node_Id) return Boolean is
+      Par : constant Node_Id := Parent (Exp);
+
+   begin
+      if No (Par) then
+         return False;
+
+      elsif Nkind (Par) in N_Declaration then
+         if Nkind (Par) = N_Object_Declaration then
+            return Present (Corresponding_Generic_Association (Par));
+         else
+            return False;
+         end if;
+
+      elsif Nkind (Par) = N_Object_Renaming_Declaration then
+         return Present (Corresponding_Generic_Association (Par));
+
+      elsif Nkind (Par) in N_Statement_Other_Than_Procedure_Call then
+         return False;
+
+      else
+         return In_Generic_Actual (Parent (Par));
+      end if;
+   end In_Generic_Actual;
+
    -----------------
    -- Is_Ancestor --
    -----------------