Commit d268147d by Ed Schonberg Committed by Arnaud Charlet

sem_prag.adb (Default_Initial_Condition): If the desired type declaration is a…

sem_prag.adb (Default_Initial_Condition): If the desired type declaration is a derived type declaration with discriminants...

2017-01-23  Ed Schonberg  <schonberg@adacore.com>

	* sem_prag.adb (Default_Initial_Condition): If the desired type
	declaration is a derived type declaration with discriminants,
	it is rewritten as a private type declaration.
	* sem_ch13.adb (Replace_Type_References_Generic,
	Visible_Component): A discriminated private type with descriminnts
	has components that must be rewritten as selected components
	if they appear as identifiers in an aspect expression such as
	a Default_Initial_Condition.
	* sem_util.adb (Defining_Entity): support N_Iterator_Specification
	nodes.

From-SVN: r244809
parent dafe11cd
2017-01-23 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb (Default_Initial_Condition): If the desired type
declaration is a derived type declaration with discriminants,
it is rewritten as a private type declaration.
* sem_ch13.adb (Replace_Type_References_Generic,
Visible_Component): A discriminated private type with descriminnts
has components that must be rewritten as selected components
if they appear as identifiers in an aspect expression such as
a Default_Initial_Condition.
* sem_util.adb (Defining_Entity): support N_Iterator_Specification
nodes.
2017-01-23 Hristian Kirtchev <kirtchev@adacore.com> 2017-01-23 Hristian Kirtchev <kirtchev@adacore.com>
* ghost.ads, ghost.adb (Is_Ignored_Ghost_Unit): New routine. * ghost.ads, ghost.adb (Is_Ignored_Ghost_Unit): New routine.
......
...@@ -12688,10 +12688,13 @@ package body Sem_Ch13 is ...@@ -12688,10 +12688,13 @@ package body Sem_Ch13 is
E : Entity_Id; E : Entity_Id;
begin begin
if Ekind (T) /= E_Record_Type then
return Empty;
else -- Types with nameable components are records and discriminated
-- private types.
if Ekind (T) = E_Record_Type
or else (Is_Private_Type (T) and then Has_Discriminants (T))
then
E := First_Entity (T); E := First_Entity (T);
while Present (E) loop while Present (E) loop
if Comes_From_Source (E) and then Chars (E) = Comp then if Comes_From_Source (E) and then Chars (E) = Comp then
...@@ -12700,9 +12703,11 @@ package body Sem_Ch13 is ...@@ -12700,9 +12703,11 @@ package body Sem_Ch13 is
Next_Entity (E); Next_Entity (E);
end loop; end loop;
return Empty;
end if; end if;
-- Nothing by that name, or type has no components.
return Empty;
end Visible_Component; end Visible_Component;
-- Start of processing for Replace_Type_References_Generic -- Start of processing for Replace_Type_References_Generic
......
...@@ -13840,9 +13840,13 @@ package body Sem_Prag is ...@@ -13840,9 +13840,13 @@ package body Sem_Prag is
Error_Msg_N ("pragma % duplicates pragma declared#", N); Error_Msg_N ("pragma % duplicates pragma declared#", N);
end if; end if;
-- Skip internally generated code -- Skip internally generated code. Note that derived type
-- declarations of untagged types with discriminants are
-- rewritten as private type declarations.
elsif not Comes_From_Source (Stmt) then elsif not Comes_From_Source (Stmt)
and then Nkind (Stmt) /= N_Private_Type_Declaration
then
null; null;
-- The associated private type [extension] has been found, stop -- The associated private type [extension] has been found, stop
...@@ -5238,6 +5238,7 @@ package body Sem_Util is ...@@ -5238,6 +5238,7 @@ package body Sem_Util is
| N_Full_Type_Declaration | N_Full_Type_Declaration
| N_Implicit_Label_Declaration | N_Implicit_Label_Declaration
| N_Incomplete_Type_Declaration | N_Incomplete_Type_Declaration
| N_Iterator_Specification
| N_Loop_Parameter_Specification | N_Loop_Parameter_Specification
| N_Number_Declaration | N_Number_Declaration
| N_Object_Declaration | N_Object_Declaration
......
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