Commit adc876a8 by Arnaud Charlet

[multiple changes]

2014-10-20  Robert Dewar  <dewar@adacore.com>

	* sem_ch3.adb, prj-proc.adb, sem_ch4.adb, prj-env.adb, lib.ads,
	sem_ch13.adb: Minor reformatting.

2014-10-20  Javier Miranda  <miranda@adacore.com>

	* exp_ch3.adb (Expand_N_Object_Declaration): Expand the
	declaration of a class-wide limited object containing an
	initializing expression into a renaming declaration.  Required to
	avoid passing such declaration to the backend and also to avoid
	generating an extra copy.

From-SVN: r216475
parent 1725676d
2014-10-20 Robert Dewar <dewar@adacore.com>
* sem_ch3.adb, prj-proc.adb, sem_ch4.adb, prj-env.adb, lib.ads,
sem_ch13.adb: Minor reformatting.
2014-10-20 Javier Miranda <miranda@adacore.com>
* exp_ch3.adb (Expand_N_Object_Declaration): Expand the
declaration of a class-wide limited object containing an
initializing expression into a renaming declaration. Required to
avoid passing such declaration to the backend and also to avoid
generating an extra copy.
2014-10-20 Eric Botcazou <ebotcazou@adacore.com> 2014-10-20 Eric Botcazou <ebotcazou@adacore.com>
* inline.adb (List_Inlining_Info): Minor tweaks. * inline.adb (List_Inlining_Info): Minor tweaks.
......
...@@ -5875,6 +5875,29 @@ package body Exp_Ch3 is ...@@ -5875,6 +5875,29 @@ package body Exp_Ch3 is
Set_Expression (N, Empty); Set_Expression (N, Empty);
return; return;
-- Handle initialization of limited tagged types
elsif Is_Tagged_Type (Typ)
and then Is_Class_Wide_Type (Typ)
and then Is_Limited_Record (Typ)
then
-- Given that the type is limited we cannot perform a copy. If
-- Expr_Q is the reference to a variable we mark the variable
-- as OK_To_Rename to expand this declaration into a renaming
-- declaration (see bellow).
if Is_Entity_Name (Expr_Q) then
Set_OK_To_Rename (Entity (Expr_Q));
-- If we cannot convert the expression into a renaming we must
-- consider it an internal error because the backend does not
-- have support to handle it.
else
pragma Assert (False);
raise Program_Error;
end if;
-- For discrete types, set the Is_Known_Valid flag if the -- For discrete types, set the Is_Known_Valid flag if the
-- initializing value is known to be valid. Only do this for -- initializing value is known to be valid. Only do this for
-- source assignments, since otherwise we can end up turning -- source assignments, since otherwise we can end up turning
......
...@@ -750,6 +750,8 @@ private ...@@ -750,6 +750,8 @@ private
pragma Inline (Unit_File_Name); pragma Inline (Unit_File_Name);
pragma Inline (Unit_Name); pragma Inline (Unit_Name);
-- The Units Table
type Unit_Record is record type Unit_Record is record
Unit_File_Name : File_Name_Type; Unit_File_Name : File_Name_Type;
Unit_Name : Unit_Name_Type; Unit_Name : Unit_Name_Type;
......
...@@ -1425,10 +1425,8 @@ package body Prj.Env is ...@@ -1425,10 +1425,8 @@ package body Prj.Env is
(Self : Project_Search_Path; (Self : Project_Search_Path;
Name : String) return String_Access Name : String) return String_Access
is is
function Find_Rts_In_Path is
function Find_Rts_In_Path is new Prj.Env.Find_Name_In_Path new Prj.Env.Find_Name_In_Path (Check_Filename => Is_Directory);
(Check_Filename => Is_Directory);
begin begin
return Find_Rts_In_Path (Self, Name); return Find_Rts_In_Path (Self, Name);
end Get_Runtime_Path; end Get_Runtime_Path;
......
...@@ -909,6 +909,7 @@ package body Prj.Proc is ...@@ -909,6 +909,7 @@ package body Prj.Proc is
elsif The_Variable.Default then elsif The_Variable.Default then
case The_Variable.Kind is case The_Variable.Kind is
when Undefined => when Undefined =>
null; null;
......
...@@ -1677,7 +1677,7 @@ package body Sem_Ch13 is ...@@ -1677,7 +1677,7 @@ package body Sem_Ch13 is
then then
Error_Msg_N Error_Msg_N
("indexing aspect can only apply to a tagged type", ("indexing aspect can only apply to a tagged type",
Aspect); Aspect);
goto Continue; goto Continue;
end if; end if;
...@@ -2711,7 +2711,7 @@ package body Sem_Ch13 is ...@@ -2711,7 +2711,7 @@ package body Sem_Ch13 is
when Aspect_Default_Component_Value => when Aspect_Default_Component_Value =>
if not (Is_Array_Type (E) if not (Is_Array_Type (E)
and then Is_Scalar_Type (Component_Type (E))) and then Is_Scalar_Type (Component_Type (E)))
then then
Error_Msg_N ("aspect Default_Component_Value can only " Error_Msg_N ("aspect Default_Component_Value can only "
& "apply to an array of scalar components", N); & "apply to an array of scalar components", N);
......
...@@ -2237,8 +2237,7 @@ package body Sem_Ch3 is ...@@ -2237,8 +2237,7 @@ package body Sem_Ch3 is
Set_Null_Present (Spec, False); Set_Null_Present (Spec, False);
Insert_Before_And_Analyze (Body_Decl, Insert_Before_And_Analyze (Body_Decl,
Make_Subprogram_Declaration (Loc, Make_Subprogram_Declaration (Loc, Specification => Spec));
Specification => Spec));
end Handle_Late_Controlled_Primitive; end Handle_Late_Controlled_Primitive;
-------------------------------- --------------------------------
...@@ -3003,7 +3002,8 @@ package body Sem_Ch3 is ...@@ -3003,7 +3002,8 @@ package body Sem_Ch3 is
T := It.Typ; T := It.Typ;
elsif It.Typ = Universal_Real elsif It.Typ = Universal_Real
or else It.Typ = Universal_Integer or else
It.Typ = Universal_Integer
then then
-- Choose universal interpretation over any other -- Choose universal interpretation over any other
...@@ -4883,8 +4883,8 @@ package body Sem_Ch3 is ...@@ -4883,8 +4883,8 @@ package body Sem_Ch3 is
and then and then
(Nkind (Parent (Generic_Parent_Type (N))) /= (Nkind (Parent (Generic_Parent_Type (N))) /=
N_Formal_Type_Declaration N_Formal_Type_Declaration
or else Nkind or else Nkind (Formal_Type_Definition
(Formal_Type_Definition (Parent (Generic_Parent_Type (N)))) /= (Parent (Generic_Parent_Type (N)))) /=
N_Formal_Private_Type_Definition) N_Formal_Private_Type_Definition)
then then
if Is_Tagged_Type (Id) then if Is_Tagged_Type (Id) then
...@@ -5329,10 +5329,9 @@ package body Sem_Ch3 is ...@@ -5329,10 +5329,9 @@ package body Sem_Ch3 is
Set_Component_Size (Implicit_Base, Uint_0); Set_Component_Size (Implicit_Base, Uint_0);
Set_Packed_Array_Impl_Type (Implicit_Base, Empty); Set_Packed_Array_Impl_Type (Implicit_Base, Empty);
Set_Has_Controlled_Component Set_Has_Controlled_Component
(Implicit_Base, Has_Controlled_Component (Implicit_Base,
(Element_Type) Has_Controlled_Component (Element_Type)
or else Is_Controlled or else Is_Controlled (Element_Type));
(Element_Type));
Set_Finalize_Storage_Only Set_Finalize_Storage_Only
(Implicit_Base, Finalize_Storage_Only (Implicit_Base, Finalize_Storage_Only
(Element_Type)); (Element_Type));
...@@ -6490,9 +6489,7 @@ package body Sem_Ch3 is ...@@ -6490,9 +6489,7 @@ package body Sem_Ch3 is
-- If we did not have a range constraint, then set the range from the -- If we did not have a range constraint, then set the range from the
-- parent type. Otherwise, the Process_Subtype call has set the bounds. -- parent type. Otherwise, the Process_Subtype call has set the bounds.
if No_Constraint if No_Constraint or else not Has_Range_Constraint (Indic) then
or else not Has_Range_Constraint (Indic)
then
Set_Scalar_Range (Derived_Type, Set_Scalar_Range (Derived_Type,
Make_Range (Loc, Make_Range (Loc,
Low_Bound => New_Copy_Tree (Type_Low_Bound (Parent_Type)), Low_Bound => New_Copy_Tree (Type_Low_Bound (Parent_Type)),
...@@ -7695,7 +7692,7 @@ package body Sem_Ch3 is ...@@ -7695,7 +7692,7 @@ package body Sem_Ch3 is
if not Has_Discriminants (Parent_Base) if not Has_Discriminants (Parent_Base)
or else or else
(Has_Unknown_Discriminants (Parent_Base) (Has_Unknown_Discriminants (Parent_Base)
and then Is_Private_Type (Parent_Base)) and then Is_Private_Type (Parent_Base))
then then
Error_Msg_N Error_Msg_N
("invalid constraint: type has no discriminant", ("invalid constraint: type has no discriminant",
...@@ -8636,8 +8633,7 @@ package body Sem_Ch3 is ...@@ -8636,8 +8633,7 @@ package body Sem_Ch3 is
-- Set SSO default for record or array type -- Set SSO default for record or array type
if (Is_Array_Type (Derived_Type) if (Is_Array_Type (Derived_Type) or else Is_Record_Type (Derived_Type))
or else Is_Record_Type (Derived_Type))
and then Is_Base_Type (Derived_Type) and then Is_Base_Type (Derived_Type)
then then
Set_Default_SSO (Derived_Type); Set_Default_SSO (Derived_Type);
...@@ -8818,7 +8814,8 @@ package body Sem_Ch3 is ...@@ -8818,7 +8814,8 @@ package body Sem_Ch3 is
-- and in family bounds. -- and in family bounds.
if Is_Concurrent_Type (Current_Scope) if Is_Concurrent_Type (Current_Scope)
or else Is_Limited_Type (Current_Scope) or else
Is_Limited_Type (Current_Scope)
then then
CR_Disc := Make_Defining_Identifier (Sloc (Discrim), Chars (Discrim)); CR_Disc := Make_Defining_Identifier (Sloc (Discrim), Chars (Discrim));
...@@ -11878,14 +11875,17 @@ package body Sem_Ch3 is ...@@ -11878,14 +11875,17 @@ package body Sem_Ch3 is
Constrain_Discriminated_Type (Desig_Subtype, S, Related_Nod, Constrain_Discriminated_Type (Desig_Subtype, S, Related_Nod,
For_Access => True); For_Access => True);
elsif (Is_Task_Type (Desig_Type) or else Is_Protected_Type (Desig_Type)) elsif Is_Concurrent_Type (Desig_Type)
and then not Is_Constrained (Desig_Type) and then not Is_Constrained (Desig_Type)
then then
Constrain_Concurrent (Desig_Subtype, S, Related_Nod, Desig_Type, ' '); Constrain_Concurrent (Desig_Subtype, S, Related_Nod, Desig_Type, ' ');
else else
Error_Msg_N ("invalid constraint on access type", S); Error_Msg_N ("invalid constraint on access type", S);
Desig_Subtype := Desig_Type; -- Ignore invalid constraint
-- We simply ignore an invalid constraint
Desig_Subtype := Desig_Type;
Constraint_OK := False; Constraint_OK := False;
end if; end if;
...@@ -15517,7 +15517,8 @@ package body Sem_Ch3 is ...@@ -15517,7 +15517,8 @@ package body Sem_Ch3 is
if Present (Discriminant_Specifications (N)) then if Present (Discriminant_Specifications (N)) then
if (Is_Elementary_Type (Parent_Type) if (Is_Elementary_Type (Parent_Type)
or else Is_Array_Type (Parent_Type)) or else
Is_Array_Type (Parent_Type))
and then not Error_Posted (N) and then not Error_Posted (N)
then then
Error_Msg_N Error_Msg_N
...@@ -20048,12 +20049,11 @@ package body Sem_Ch3 is ...@@ -20048,12 +20049,11 @@ package body Sem_Ch3 is
if Ekind (Root_Type (Entity (T))) = E_Incomplete_Type if Ekind (Root_Type (Entity (T))) = E_Incomplete_Type
and then and then
not (Ada_Version >= Ada_2005 not (Ada_Version >= Ada_2005
and then and then
(Nkind (Parent (T)) = N_Subtype_Declaration (Nkind (Parent (T)) = N_Subtype_Declaration
or else or else (Nkind (Parent (T)) = N_Subtype_Indication
(Nkind (Parent (T)) = N_Subtype_Indication and then Nkind (Parent (Parent (T))) =
and then Nkind (Parent (Parent (T))) = N_Subtype_Declaration)))
N_Subtype_Declaration)))
then then
Error_Msg_N ("invalid use of type before its full declaration", T); Error_Msg_N ("invalid use of type before its full declaration", T);
end if; end if;
......
...@@ -2198,10 +2198,10 @@ package body Sem_Ch4 is ...@@ -2198,10 +2198,10 @@ package body Sem_Ch4 is
and then Is_Discrete_Type (Entity (Actual)) and then Is_Discrete_Type (Entity (Actual))
then then
Replace (N, Replace (N,
Make_Slice (Loc, Make_Slice (Loc,
Prefix => P, Prefix => P,
Discrete_Range => Discrete_Range =>
New_Occurrence_Of (Entity (Actual), Loc))); New_Occurrence_Of (Entity (Actual), Loc)));
Analyze (N); Analyze (N);
return; return;
......
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