Commit dd89dddf by Arnaud Charlet

[multiple changes]

2017-09-06  Ed Schonberg  <schonberg@adacore.com>

	* einfo.adb (Designated_Type): Use Is_Incomplete_Type to handle
	properly incomplete subtypes that may be created by explicit or
	implicit declarations.
	(Is_Base_Type): Take E_Incomplete_Subtype into account.
	(Subtype_Kind): Ditto.
	* sem_ch3.adb (Build_Discriminated_Subtype): Set properly the
	Ekind of a subtype of a discriminated incomplete type.
	(Fixup_Bad_Constraint): Use Subtype_Kind in all cases, including
	incomplete types, to preserve error reporting.
	(Process_Incomplete_Dependents): Do not create a subtype
	declaration for an incomplete subtype that is created internally.
	* sem_ch7.adb (Analyze_Package_Specification): Handle properly
	incomplete subtypes that do not require a completion, either
	because they are limited views, of they are generic actuals.

2017-09-06  Hristian Kirtchev  <kirtchev@adacore.com>

	* checks.adb (Insert_Valid_Check): Remove the
	suspicious manipulation of the Do_Range_Check flag as ths is
	no linger needed. Suppress validity check when analysing the
	validation variable.

2017-09-06  Philippe Gil  <gil@adacore.com>

	* g-debpoo.adb: adapt GNAT.Debug_Pools to allow safe thread
	GNATCOLL.Memory

2017-09-06  Bob Duff  <duff@adacore.com>

	* sem_elim.adb: Minor comment fix.

2017-09-06  Ed Schonberg  <schonberg@adacore.com>

	* sem_util.adb (Is_Object_Reference): A function call is an
	object reference, and thus attribute references for attributes
	that are functions (such as Pred and Succ) as well as predefined
	operators are legal in contexts that require an object, such as
	the prefix of attribute Img and the Ada2020 version of 'Image.

From-SVN: r251759
parent 3e720c96
2017-09-06 Ed Schonberg <schonberg@adacore.com>
* einfo.adb (Designated_Type): Use Is_Incomplete_Type to handle
properly incomplete subtypes that may be created by explicit or
implicit declarations.
(Is_Base_Type): Take E_Incomplete_Subtype into account.
(Subtype_Kind): Ditto.
* sem_ch3.adb (Build_Discriminated_Subtype): Set properly the
Ekind of a subtype of a discriminated incomplete type.
(Fixup_Bad_Constraint): Use Subtype_Kind in all cases, including
incomplete types, to preserve error reporting.
(Process_Incomplete_Dependents): Do not create a subtype
declaration for an incomplete subtype that is created internally.
* sem_ch7.adb (Analyze_Package_Specification): Handle properly
incomplete subtypes that do not require a completion, either
because they are limited views, of they are generic actuals.
2017-09-06 Hristian Kirtchev <kirtchev@adacore.com>
* checks.adb (Insert_Valid_Check): Remove the
suspicious manipulation of the Do_Range_Check flag as ths is
no linger needed. Suppress validity check when analysing the
validation variable.
2017-09-06 Philippe Gil <gil@adacore.com>
* g-debpoo.adb: adapt GNAT.Debug_Pools to allow safe thread
GNATCOLL.Memory
2017-09-06 Bob Duff <duff@adacore.com>
* sem_elim.adb: Minor comment fix.
2017-09-06 Ed Schonberg <schonberg@adacore.com>
* sem_util.adb (Is_Object_Reference): A function call is an
object reference, and thus attribute references for attributes
that are functions (such as Pred and Succ) as well as predefined
operators are legal in contexts that require an object, such as
the prefix of attribute Img and the Ada2020 version of 'Image.
2017-09-06 Hristian Kirtchev <kirtchev@adacore.com>
* exp_util.adb, einfo.adb, sem_attr.adb, exp_ch4.adb, gnatls.adb,
......
......@@ -7333,21 +7333,12 @@ package body Checks is
return;
end if;
-- We are about to insert the validity check for Exp. We save and
-- reset the Do_Range_Check flag over this validity check, and then
-- put it back for the final original reference (Exp may be rewritten).
declare
DRC : constant Boolean := Do_Range_Check (Exp);
CE : Node_Id;
Obj : Node_Id;
PV : Node_Id;
Var_Id : Entity_Id;
begin
Set_Do_Range_Check (Exp, False);
-- If the expression denotes an assignable object, capture its value
-- in a variable and replace the original expression by the variable.
-- This approach has several effects:
......@@ -7386,15 +7377,16 @@ package body Checks is
-- Object := Var; -- update Object
if Is_Variable (Exp) then
Obj := New_Copy_Tree (Exp);
Var_Id := Make_Temporary (Loc, 'T', Exp);
Insert_Action (Exp,
Make_Object_Declaration (Loc,
Defining_Identifier => Var_Id,
Object_Definition => New_Occurrence_Of (Typ, Loc),
Expression => Relocate_Node (Exp)));
Set_Validated_Object (Var_Id, Obj);
Expression => New_Copy_Tree (Exp)),
Suppress => Validity_Check);
Set_Validated_Object (Var_Id, New_Copy_Tree (Exp));
Rewrite (Exp, New_Occurrence_Of (Var_Id, Loc));
PV := New_Occurrence_Of (Var_Id, Loc);
......@@ -7474,20 +7466,6 @@ package body Checks is
end if;
end;
end if;
-- Put back the Do_Range_Check flag on the resulting (possibly
-- rewritten) expression.
-- Note: it might be thought that a validity check is not required
-- when a range check is present, but that's not the case, because
-- the back end is allowed to assume for the range check that the
-- operand is within its declared range (an assumption that validity
-- checking is all about NOT assuming).
-- Note: no need to worry about Possible_Local_Raise here, it will
-- already have been called if original node has Do_Range_Check set.
Set_Do_Range_Check (Exp, DRC);
end;
end Insert_Valid_Check;
......
......@@ -7151,13 +7151,13 @@ package body Einfo is
begin
Desig_Type := Directly_Designated_Type (Id);
if Ekind (Desig_Type) = E_Incomplete_Type
if Is_Incomplete_Type (Desig_Type)
and then Present (Full_View (Desig_Type))
then
return Full_View (Desig_Type);
elsif Is_Class_Wide_Type (Desig_Type)
and then Ekind (Etype (Desig_Type)) = E_Incomplete_Type
and then Is_Incomplete_Type (Etype (Desig_Type))
and then Present (Full_View (Etype (Desig_Type)))
and then Present (Class_Wide_Type (Full_View (Etype (Desig_Type))))
then
......@@ -7364,11 +7364,11 @@ package body Einfo is
function Get_Full_View (T : Entity_Id) return Entity_Id is
begin
if Ekind (T) = E_Incomplete_Type and then Present (Full_View (T)) then
if Is_Incomplete_Type (T) and then Present (Full_View (T)) then
return Full_View (T);
elsif Is_Class_Wide_Type (T)
and then Ekind (Root_Type (T)) = E_Incomplete_Type
and then Is_Incomplete_Type (Root_Type (T))
and then Present (Full_View (Root_Type (T)))
then
return Class_Wide_Type (Full_View (Root_Type (T)));
......@@ -7800,7 +7800,7 @@ package body Einfo is
Entity_Is_Base_Type : constant array (Entity_Kind) of Boolean :=
(E_Enumeration_Subtype |
E_Incomplete_Type |
E_Incomplete_Subtype |
E_Signed_Integer_Subtype |
E_Modular_Integer_Subtype |
E_Floating_Point_Subtype |
......@@ -9174,6 +9174,9 @@ package body Einfo is
when Enumeration_Kind =>
Kind := E_Enumeration_Subtype;
when E_Incomplete_Type =>
Kind := E_Incomplete_Subtype;
when Float_Kind =>
Kind := E_Floating_Point_Subtype;
......
......@@ -10094,7 +10094,11 @@ package body Sem_Ch3 is
-- elaboration, because only the access type is needed in the
-- initialization procedure.
Set_Ekind (Def_Id, Ekind (T));
if Ekind (T) = E_Incomplete_Type then
Set_Ekind (Def_Id, E_Incomplete_Subtype);
else
Set_Ekind (Def_Id, Ekind (T));
end if;
if For_Access and then Within_Init_Proc then
null;
......@@ -13629,15 +13633,9 @@ package body Sem_Ch3 is
procedure Fixup_Bad_Constraint is
begin
-- Set a reasonable Ekind for the entity. For an incomplete type,
-- we can't do much, but for other types, we can set the proper
-- corresponding subtype kind.
-- Set a reasonable Ekind for the entity, including incomplete types.
if Ekind (T) = E_Incomplete_Type then
Set_Ekind (Def_Id, Ekind (T));
else
Set_Ekind (Def_Id, Subtype_Kind (Ekind (T)));
end if;
Set_Ekind (Def_Id, Subtype_Kind (Ekind (T)));
-- Set Etype to the known type, to reduce chances of cascaded errors
......@@ -20802,7 +20800,9 @@ package body Sem_Ch3 is
-- Ada 2005 (AI-412): Transform a regular incomplete subtype into a
-- corresponding subtype of the full view.
elsif Ekind (Priv_Dep) = E_Incomplete_Subtype then
elsif Ekind (Priv_Dep) = E_Incomplete_Subtype
and then Comes_From_Source (Priv_Dep)
then
Set_Subtype_Indication
(Parent (Priv_Dep), New_Occurrence_Of (Full_T, Sloc (Priv_Dep)));
Set_Etype (Priv_Dep, Full_T);
......
......@@ -1441,11 +1441,14 @@ package body Sem_Ch7 is
-- Check on incomplete types
-- AI05-0213: A formal incomplete type has no completion
-- AI05-0213: A formal incomplete type has no completion,
-- and neither does the corresponding subtype in an instance.
if Ekind (E) = E_Incomplete_Type
if Is_Incomplete_Type (E)
and then No (Full_View (E))
and then not Is_Generic_Type (E)
and then not From_Limited_With (E)
and then not Is_Generic_Actual_Type (E)
then
Error_Msg_N ("no declaration in visible part for incomplete}", E);
end if;
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1997-2016, Free Software Foundation, Inc. --
-- Copyright (C) 1997-2017, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -194,7 +194,7 @@ package body Sem_Elim is
-- Tables --
------------
-- The following table records the data for each pragmas, using the
-- The following table records the data for each pragma, using the
-- entity name as the hash key for retrieval. Entries in this table
-- are set by Process_Eliminate_Pragma and read by Check_Eliminated.
......
......@@ -14153,18 +14153,21 @@ package body Sem_Util is
-- In Ada 95, a function call is a constant object; a procedure
-- call is not.
when N_Function_Call =>
-- Note that predefined operators are functions as well, and so
-- are attributes that are (can be renamed as) functions.
when N_Function_Call | N_Binary_Op | N_Unary_Op =>
return Etype (N) /= Standard_Void_Type;
-- Attributes 'Input, 'Loop_Entry, 'Old, and 'Result produce
-- objects.
-- Attributes references 'Loop_Entry, 'Old, and 'Result yield
-- objects, even though they are not functions.
when N_Attribute_Reference =>
return
Nam_In (Attribute_Name (N), Name_Input,
Name_Loop_Entry,
Nam_In (Attribute_Name (N), Name_Loop_Entry,
Name_Old,
Name_Result);
Name_Result)
or else Is_Function_Attribute_Name (Attribute_Name (N));
when N_Selected_Component =>
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