Commit 718deaf1 by Arnaud Charlet

[multiple changes]

2010-10-12  Robert Dewar  <dewar@adacore.com>

	* aspects.ads, aspects.adb (Move_Aspects): New procedure.
	* atree.ads, atree.adb: (New_Copy): Does not copy aspect specifications
	* sinfo.ads, par-ch3.adb, par-ch6.adb, par-ch7.adb, par-ch9.adb,
	par-endh.adb, par-ch13.adb, par-ch12.adb: Modify grammar to include
	aspect specifications.
	Recognize aspect specifications for all cases
	* par.adb: Recognize aspect specifications for all cases
	* sem_ch12.ads, sem_ch12.adb (Copy_Generic_Node): Copies aspect
	specifications.
	* sem_ch3.adb (Analyze_Subtype_Declaration): Improve patch to freeze
	generic actual types (was missing some guards before).
	* sem_ch9.adb (Analyze_Single_Protected_Declaration): Copy aspects to
	generated object
	(Analyze_Single_Task_Declaration): Copy aspects to generated object

2010-10-12  Eric Botcazou  <ebotcazou@adacore.com>

	* usage.adb (usage): Adjust line for -gnatn switch.

2010-10-12  Robert Dewar  <dewar@adacore.com>

	* sem_attr.adb (Eval_Attribute): Only leave change active for aspect
	spec case.

2010-10-12  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch6.adb (Analyze_Subprogram_Declaration): If this is a
	declaration of a null procedure resolve the types of the profile of the
	generated null body now.

From-SVN: r165353
parent 6832435e
2010-10-12 Robert Dewar <dewar@adacore.com>
* aspects.ads, aspects.adb (Move_Aspects): New procedure.
* atree.ads, atree.adb: (New_Copy): Does not copy aspect specifications
* sinfo.ads, par-ch3.adb, par-ch6.adb, par-ch7.adb, par-ch9.adb,
par-endh.adb, par-ch13.adb, par-ch12.adb: Modify grammar to include
aspect specifications.
Recognize aspect specifications for all cases
* par.adb: Recognize aspect specifications for all cases
* sem_ch12.ads, sem_ch12.adb (Copy_Generic_Node): Copies aspect
specifications.
* sem_ch3.adb (Analyze_Subtype_Declaration): Improve patch to freeze
generic actual types (was missing some guards before).
* sem_ch9.adb (Analyze_Single_Protected_Declaration): Copy aspects to
generated object
(Analyze_Single_Task_Declaration): Copy aspects to generated object
2010-10-12 Eric Botcazou <ebotcazou@adacore.com>
* usage.adb (usage): Adjust line for -gnatn switch.
2010-10-12 Robert Dewar <dewar@adacore.com>
* sem_attr.adb (Eval_Attribute): Only leave change active for aspect
spec case.
2010-10-12 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Analyze_Subprogram_Declaration): If this is a
declaration of a null procedure resolve the types of the profile of the
generated null body now.
2010-10-11 Robert Dewar <dewar@adacore.com> 2010-10-11 Robert Dewar <dewar@adacore.com>
* debug.adb: Remove d.A flag to delay address clause (not needed any * debug.adb: Remove d.A flag to delay address clause (not needed any
......
...@@ -160,6 +160,20 @@ package body Aspects is ...@@ -160,6 +160,20 @@ package body Aspects is
end if; end if;
end Aspect_Specifications; end Aspect_Specifications;
------------------
-- Move_Aspects --
------------------
procedure Move_Aspects (From : Node_Id; To : Node_Id) is
pragma Assert (not Has_Aspects (To));
begin
if Has_Aspects (From) then
Set_Aspect_Specifications (To, Aspect_Specifications (From));
Aspect_Specifications_Hash_Table.Remove (From);
Set_Has_Aspects (From, False);
end if;
end Move_Aspects;
----------------------------------- -----------------------------------
-- Permits_Aspect_Specifications -- -- Permits_Aspect_Specifications --
----------------------------------- -----------------------------------
......
...@@ -195,6 +195,12 @@ package Aspects is ...@@ -195,6 +195,12 @@ package Aspects is
-- node that has its Has_Aspects flag set True on entry, or with L being an -- node that has its Has_Aspects flag set True on entry, or with L being an
-- empty list or No_List. -- empty list or No_List.
procedure Move_Aspects (From : Node_Id; To : Node_Id);
-- Moves aspects from 'From' node to 'To' node. Has_Aspects (To) must be
-- False on entry. If Has_Aspects (From) is False, the call has no effect.
-- Otherwise the aspects are moved and on return Has_Aspects (To) is True,
-- and Has_Aspects (From) is False.
procedure Tree_Write; procedure Tree_Write;
-- Writes contents of Aspect_Specifications hash table to the tree file -- Writes contents of Aspect_Specifications hash table to the tree file
......
...@@ -1191,7 +1191,6 @@ package body Atree is ...@@ -1191,7 +1191,6 @@ package body Atree is
begin begin
if Source > Empty_Or_Error then if Source > Empty_Or_Error then
New_Id := Allocate_Initialize_Node (Source, Has_Extension (Source)); New_Id := Allocate_Initialize_Node (Source, Has_Extension (Source));
Nodes.Table (New_Id).Link := Empty_List_Or_Node; Nodes.Table (New_Id).Link := Empty_List_Or_Node;
...@@ -1202,6 +1201,11 @@ package body Atree is ...@@ -1202,6 +1201,11 @@ package body Atree is
Nodes.Table (New_Id).Rewrite_Ins := False; Nodes.Table (New_Id).Rewrite_Ins := False;
pragma Debug (New_Node_Debugging_Output (New_Id)); pragma Debug (New_Node_Debugging_Output (New_Id));
-- Always clear Has_Aspects, the caller must take care of copying
-- aspects if this is required for the particular situation.
Set_Has_Aspects (New_Id, False);
end if; end if;
return New_Id; return New_Id;
...@@ -1659,6 +1663,7 @@ package body Atree is ...@@ -1659,6 +1663,7 @@ package body Atree is
-- of aspect specifications if aspect specifications are present. -- of aspect specifications if aspect specifications are present.
if Has_Aspects (Sav_Node) then if Has_Aspects (Sav_Node) then
Set_Has_Aspects (Sav_Node, False);
Set_Aspect_Specifications Set_Aspect_Specifications
(Sav_Node, Aspect_Specifications (Old_Node)); (Sav_Node, Aspect_Specifications (Old_Node));
end if; end if;
......
...@@ -398,7 +398,10 @@ package Atree is ...@@ -398,7 +398,10 @@ package Atree is
-- The parent pointer of the destination and its list link, if any, are -- The parent pointer of the destination and its list link, if any, are
-- not affected by the copy. Note that parent pointers of descendents -- not affected by the copy. Note that parent pointers of descendents
-- are not adjusted, so the descendents of the destination node after -- are not adjusted, so the descendents of the destination node after
-- the Copy_Node is completed have dubious parent pointers. -- the Copy_Node is completed have dubious parent pointers. Note that
-- this routine does NOT copy aspect specifications, the Has_Aspects
-- flag in the returned node will always be False. The caller must deal
-- with copying aspect specifications where this is required.
function New_Copy (Source : Node_Id) return Node_Id; function New_Copy (Source : Node_Id) return Node_Id;
-- This function allocates a completely new node, and then initializes -- This function allocates a completely new node, and then initializes
......
...@@ -61,10 +61,12 @@ package body Ch12 is ...@@ -61,10 +61,12 @@ package body Ch12 is
-- GENERIC_SUBPROGRAM_DECLARATION | GENERIC_PACKAGE_DECLARATION -- GENERIC_SUBPROGRAM_DECLARATION | GENERIC_PACKAGE_DECLARATION
-- GENERIC_SUBPROGRAM_DECLARATION ::= -- GENERIC_SUBPROGRAM_DECLARATION ::=
-- GENERIC_FORMAL_PART SUBPROGRAM_SPECIFICATION; -- GENERIC_FORMAL_PART SUBPROGRAM_SPECIFICATION
-- [ASPECT_SPECIFICATIONS];
-- GENERIC_PACKAGE_DECLARATION ::= -- GENERIC_PACKAGE_DECLARATION ::=
-- GENERIC_FORMAL_PART PACKAGE_SPECIFICATION; -- GENERIC_FORMAL_PART PACKAGE_SPECIFICATION
-- [ASPECT_SPECIFICATIONS];
-- GENERIC_FORMAL_PART ::= -- GENERIC_FORMAL_PART ::=
-- generic {GENERIC_FORMAL_PARAMETER_DECLARATION | USE_CLAUSE} -- generic {GENERIC_FORMAL_PARAMETER_DECLARATION | USE_CLAUSE}
...@@ -194,14 +196,14 @@ package body Ch12 is ...@@ -194,14 +196,14 @@ package body Ch12 is
exit Decl_Loop; exit Decl_Loop;
end if; end if;
end if; end if;
end loop Decl_Loop; end loop Decl_Loop;
-- Generic formal part is scanned, scan out subprogram or package spec -- Generic formal part is scanned, scan out subprogram or package spec
if Token = Tok_Package then if Token = Tok_Package then
Gen_Decl := New_Node (N_Generic_Package_Declaration, Gen_Sloc); Gen_Decl := New_Node (N_Generic_Package_Declaration, Gen_Sloc);
Set_Specification (Gen_Decl, P_Package (Pf_Spcn)); Set_Specification (Gen_Decl, P_Package (Pf_Spcn, Gen_Decl));
else else
Gen_Decl := New_Node (N_Generic_Subprogram_Declaration, Gen_Sloc); Gen_Decl := New_Node (N_Generic_Subprogram_Declaration, Gen_Sloc);
...@@ -213,7 +215,8 @@ package body Ch12 is ...@@ -213,7 +215,8 @@ package body Ch12 is
then then
Error_Msg_SP ("child unit allowed only at library level"); Error_Msg_SP ("child unit allowed only at library level");
end if; end if;
TF_Semicolon;
P_Aspect_Specifications (Gen_Decl);
end if; end if;
Set_Generic_Formal_Declarations (Gen_Decl, Decls); Set_Generic_Formal_Declarations (Gen_Decl, Decls);
...@@ -275,8 +278,9 @@ package body Ch12 is ...@@ -275,8 +278,9 @@ package body Ch12 is
begin begin
-- Figure out if a generic actual part operation is present. Clearly -- Figure out if a generic actual part operation is present. Clearly
-- there is no generic actual part if the current token is semicolon -- there is no generic actual part if the current token is semicolon
-- or if we have apsect specifications present.
if Token = Tok_Semicolon then if Token = Tok_Semicolon or else Aspect_Specifications_Present then
return No_List; return No_List;
-- If we don't have a left paren, then we have an error, and the job -- If we don't have a left paren, then we have an error, and the job
...@@ -402,9 +406,11 @@ package body Ch12 is ...@@ -402,9 +406,11 @@ package body Ch12 is
-- FORMAL_OBJECT_DECLARATION ::= -- FORMAL_OBJECT_DECLARATION ::=
-- DEFINING_IDENTIFIER_LIST : -- DEFINING_IDENTIFIER_LIST :
-- MODE [NULL_EXCLUSION] SUBTYPE_MARK [:= DEFAULT_EXPRESSION]; -- MODE [NULL_EXCLUSION] SUBTYPE_MARK [:= DEFAULT_EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- | DEFINING_IDENTIFIER_LIST : -- | DEFINING_IDENTIFIER_LIST :
-- MODE ACCESS_DEFINITION [:= DEFAULT_EXPRESSION]; -- MODE ACCESS_DEFINITION [:= DEFAULT_EXPRESSION];
-- [ASPECT_SPECIFICATIONS];
-- The caller has checked that the initial token is an identifier -- The caller has checked that the initial token is an identifier
...@@ -425,7 +431,6 @@ package body Ch12 is ...@@ -425,7 +431,6 @@ package body Ch12 is
begin begin
Idents (1) := P_Defining_Identifier (C_Comma_Colon); Idents (1) := P_Defining_Identifier (C_Comma_Colon);
Num_Idents := 1; Num_Idents := 1;
while Comma_Present loop while Comma_Present loop
Num_Idents := Num_Idents + 1; Num_Idents := Num_Idents + 1;
Idents (Num_Idents) := P_Defining_Identifier (C_Comma_Colon); Idents (Num_Idents) := P_Defining_Identifier (C_Comma_Colon);
...@@ -479,6 +484,7 @@ package body Ch12 is ...@@ -479,6 +484,7 @@ package body Ch12 is
No_Constraint; No_Constraint;
Set_Default_Expression (Decl_Node, Init_Expr_Opt); Set_Default_Expression (Decl_Node, Init_Expr_Opt);
P_Aspect_Specifications (Decl_Node);
if Ident > 1 then if Ident > 1 then
Set_Prev_Ids (Decl_Node, True); Set_Prev_Ids (Decl_Node, True);
...@@ -494,8 +500,6 @@ package body Ch12 is ...@@ -494,8 +500,6 @@ package body Ch12 is
Ident := Ident + 1; Ident := Ident + 1;
Restore_Scan_State (Scan_State); Restore_Scan_State (Scan_State);
end loop Ident_Loop; end loop Ident_Loop;
TF_Semicolon;
end P_Formal_Object_Declarations; end P_Formal_Object_Declarations;
----------------------------------- -----------------------------------
...@@ -504,7 +508,8 @@ package body Ch12 is ...@@ -504,7 +508,8 @@ package body Ch12 is
-- FORMAL_TYPE_DECLARATION ::= -- FORMAL_TYPE_DECLARATION ::=
-- type DEFINING_IDENTIFIER [DISCRIMINANT_PART] -- type DEFINING_IDENTIFIER [DISCRIMINANT_PART]
-- is FORMAL_TYPE_DEFINITION; -- is FORMAL_TYPE_DEFINITION
-- [ASPECT_SPECIFICATIONS];
-- The caller has checked that the initial token is TYPE -- The caller has checked that the initial token is TYPE
...@@ -532,15 +537,20 @@ package body Ch12 is ...@@ -532,15 +537,20 @@ package body Ch12 is
if Def_Node /= Error then if Def_Node /= Error then
Set_Formal_Type_Definition (Decl_Node, Def_Node); Set_Formal_Type_Definition (Decl_Node, Def_Node);
TF_Semicolon; P_Aspect_Specifications (Decl_Node);
else else
Decl_Node := Error; Decl_Node := Error;
-- If we have aspect specifications, skip them
if Aspect_Specifications_Present then
P_Aspect_Specifications (Error);
-- If we have semicolon, skip it to avoid cascaded errors -- If we have semicolon, skip it to avoid cascaded errors
if Token = Tok_Semicolon then elsif Token = Tok_Semicolon then
Scan; Scan; -- past semicolon
end if; end if;
end if; end if;
...@@ -1078,10 +1088,12 @@ package body Ch12 is ...@@ -1078,10 +1088,12 @@ package body Ch12 is
-- | FORMAL_ABSTRACT_SUBPROGRAM_DECLARATION -- | FORMAL_ABSTRACT_SUBPROGRAM_DECLARATION
-- FORMAL_CONCRETE_SUBPROGRAM_DECLARATION ::= -- FORMAL_CONCRETE_SUBPROGRAM_DECLARATION ::=
-- with SUBPROGRAM_SPECIFICATION [is SUBPROGRAM_DEFAULT]; -- with SUBPROGRAM_SPECIFICATION [is SUBPROGRAM_DEFAULT]
-- [ASPECT_SPECIFICATIONS];
-- FORMAL_ABSTRACT_SUBPROGRAM_DECLARATION ::= -- FORMAL_ABSTRACT_SUBPROGRAM_DECLARATION ::=
-- with SUBPROGRAM_SPECIFICATION is abstract [SUBPROGRAM_DEFAULT]; -- with SUBPROGRAM_SPECIFICATION is abstract [SUBPROGRAM_DEFAULT]
-- [ASPECT_SPECIFICATIONS];
-- SUBPROGRAM_DEFAULT ::= DEFAULT_NAME | <> -- SUBPROGRAM_DEFAULT ::= DEFAULT_NAME | <>
...@@ -1122,12 +1134,14 @@ package body Ch12 is ...@@ -1122,12 +1134,14 @@ package body Ch12 is
Set_Specification (Def_Node, Spec_Node); Set_Specification (Def_Node, Spec_Node);
if Token = Tok_Semicolon then if Token = Tok_Semicolon then
Scan; -- past ";" null;
elsif Aspect_Specifications_Present then
null;
elsif Token = Tok_Box then elsif Token = Tok_Box then
Set_Box_Present (Def_Node, True); Set_Box_Present (Def_Node, True);
Scan; -- past <> Scan; -- past <>
T_Semicolon;
elsif Token = Tok_Null then elsif Token = Tok_Null then
if Ada_Version < Ada_2005 then if Ada_Version < Ada_2005 then
...@@ -1143,20 +1157,18 @@ package body Ch12 is ...@@ -1143,20 +1157,18 @@ package body Ch12 is
end if; end if;
Scan; -- past NULL Scan; -- past NULL
T_Semicolon;
else else
Set_Default_Name (Def_Node, P_Name); Set_Default_Name (Def_Node, P_Name);
T_Semicolon;
end if; end if;
else else
Def_Node := Def_Node :=
New_Node (N_Formal_Concrete_Subprogram_Declaration, Prev_Sloc); New_Node (N_Formal_Concrete_Subprogram_Declaration, Prev_Sloc);
Set_Specification (Def_Node, Spec_Node); Set_Specification (Def_Node, Spec_Node);
T_Semicolon;
end if; end if;
P_Aspect_Specifications (Def_Node);
return Def_Node; return Def_Node;
end P_Formal_Subprogram_Declaration; end P_Formal_Subprogram_Declaration;
...@@ -1178,7 +1190,8 @@ package body Ch12 is ...@@ -1178,7 +1190,8 @@ package body Ch12 is
-- FORMAL_PACKAGE_DECLARATION ::= -- FORMAL_PACKAGE_DECLARATION ::=
-- with package DEFINING_IDENTIFIER -- with package DEFINING_IDENTIFIER
-- is new generic_package_NAME FORMAL_PACKAGE_ACTUAL_PART; -- is new generic_package_NAME FORMAL_PACKAGE_ACTUAL_PART
-- [ASPECT_SPECIFICATIONS];
-- FORMAL_PACKAGE_ACTUAL_PART ::= -- FORMAL_PACKAGE_ACTUAL_PART ::=
-- ([OTHERS =>] <>) | -- ([OTHERS =>] <>) |
...@@ -1222,7 +1235,7 @@ package body Ch12 is ...@@ -1222,7 +1235,7 @@ package body Ch12 is
end if; end if;
end if; end if;
T_Semicolon; P_Aspect_Specifications (Def_Node);
return Def_Node; return Def_Node;
end P_Formal_Package_Declaration; end P_Formal_Package_Declaration;
......
...@@ -378,17 +378,19 @@ package body Ch13 is ...@@ -378,17 +378,19 @@ package body Ch13 is
Aspect : Node_Id; Aspect : Node_Id;
A_Id : Aspect_Id; A_Id : Aspect_Id;
OK : Boolean; OK : Boolean;
Ptr : Source_Ptr;
begin begin
-- Check if aspect specification present -- Check if aspect specification present
if not Aspect_Specifications_Present then if not Aspect_Specifications_Present then
T_Semicolon; TF_Semicolon;
return; return;
end if; end if;
-- Aspect Specification is present -- Aspect Specification is present
Ptr := Token_Ptr;
Scan; -- past WITH Scan; -- past WITH
-- Here we have an aspect specification to scan, note that we don;t -- Here we have an aspect specification to scan, note that we don;t
...@@ -511,8 +513,12 @@ package body Ch13 is ...@@ -511,8 +513,12 @@ package body Ch13 is
-- If aspects scanned, store them -- If aspects scanned, store them
if Is_Non_Empty_List (Aspects) then if Is_Non_Empty_List (Aspects) then
Set_Parent (Aspects, Decl); if Decl = Error then
Set_Aspect_Specifications (Decl, Aspects); Error_Msg ("aspect specifications not allowed here", Ptr);
else
Set_Parent (Aspects, Decl);
Set_Aspect_Specifications (Decl, Aspects);
end if;
end if; end if;
end P_Aspect_Specifications; end P_Aspect_Specifications;
......
...@@ -276,7 +276,8 @@ package body Ch3 is ...@@ -276,7 +276,8 @@ package body Ch3 is
-- | PRIVATE_EXTENSION_DECLARATION -- | PRIVATE_EXTENSION_DECLARATION
-- FULL_TYPE_DECLARATION ::= -- FULL_TYPE_DECLARATION ::=
-- type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART] is TYPE_DEFINITION; -- type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART] is TYPE_DEFINITION
-- [ASPECT_SPECIFICATIONS];
-- | CONCURRENT_TYPE_DECLARATION -- | CONCURRENT_TYPE_DECLARATION
-- INCOMPLETE_TYPE_DECLARATION ::= -- INCOMPLETE_TYPE_DECLARATION ::=
...@@ -1260,11 +1261,14 @@ package body Ch3 is ...@@ -1260,11 +1261,14 @@ package body Ch3 is
-- OBJECT_DECLARATION ::= -- OBJECT_DECLARATION ::=
-- DEFINING_IDENTIFIER_LIST : [aliased] [constant] -- DEFINING_IDENTIFIER_LIST : [aliased] [constant]
-- [NULL_EXCLUSION] SUBTYPE_INDICATION [:= EXPRESSION]; -- [NULL_EXCLUSION] SUBTYPE_INDICATION [:= EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- | DEFINING_IDENTIFIER_LIST : [aliased] [constant] -- | DEFINING_IDENTIFIER_LIST : [aliased] [constant]
-- ACCESS_DEFINITION [:= EXPRESSION]; -- ACCESS_DEFINITION [:= EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- | DEFINING_IDENTIFIER_LIST : [aliased] [constant] -- | DEFINING_IDENTIFIER_LIST : [aliased] [constant]
-- ARRAY_TYPE_DEFINITION [:= EXPRESSION]; -- ARRAY_TYPE_DEFINITION [:= EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- NUMBER_DECLARATION ::= -- NUMBER_DECLARATION ::=
-- DEFINING_IDENTIFIER_LIST : constant ::= static_EXPRESSION; -- DEFINING_IDENTIFIER_LIST : constant ::= static_EXPRESSION;
...@@ -1279,7 +1283,8 @@ package body Ch3 is ...@@ -1279,7 +1283,8 @@ package body Ch3 is
-- DEFINING_IDENTIFIER : exception renames exception_NAME; -- DEFINING_IDENTIFIER : exception renames exception_NAME;
-- EXCEPTION_DECLARATION ::= -- EXCEPTION_DECLARATION ::=
-- DEFINING_IDENTIFIER_LIST : exception; -- DEFINING_IDENTIFIER_LIST : exception
-- [ASPECT_SPECIFICATIONS];
-- Note that the ALIASED indication in an object declaration is -- Note that the ALIASED indication in an object declaration is
-- marked by a flag in the parent node. -- marked by a flag in the parent node.
...@@ -3322,7 +3327,8 @@ package body Ch3 is ...@@ -3322,7 +3327,8 @@ package body Ch3 is
-- COMPONENT_DECLARATION ::= -- COMPONENT_DECLARATION ::=
-- DEFINING_IDENTIFIER_LIST : COMPONENT_DEFINITION -- DEFINING_IDENTIFIER_LIST : COMPONENT_DEFINITION
-- [:= DEFAULT_EXPRESSION]; -- [:= DEFAULT_EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- COMPONENT_DEFINITION ::= -- COMPONENT_DEFINITION ::=
-- [aliased] [NULL_EXCLUSION] SUBTYPE_INDICATION | ACCESS_DEFINITION -- [aliased] [NULL_EXCLUSION] SUBTYPE_INDICATION | ACCESS_DEFINITION
......
...@@ -84,10 +84,13 @@ package body Ch6 is ...@@ -84,10 +84,13 @@ package body Ch6 is
-- subprogram renaming declaration or subprogram generic instantiation. -- subprogram renaming declaration or subprogram generic instantiation.
-- It also handles the new Ada 2012 parameterized expression form -- It also handles the new Ada 2012 parameterized expression form
-- SUBPROGRAM_DECLARATION ::= SUBPROGRAM_SPECIFICATION; -- SUBPROGRAM_DECLARATION ::=
-- SUBPROGRAM_SPECIFICATION
-- [ASPECT_SPECIFICATIONS];
-- ABSTRACT_SUBPROGRAM_DECLARATION ::= -- ABSTRACT_SUBPROGRAM_DECLARATION ::=
-- SUBPROGRAM_SPECIFICATION is abstract; -- SUBPROGRAM_SPECIFICATION is abstract
-- [ASPECT_SPECIFICATIONS];
-- SUBPROGRAM_SPECIFICATION ::= -- SUBPROGRAM_SPECIFICATION ::=
-- procedure DEFINING_PROGRAM_UNIT_NAME PARAMETER_PROFILE -- procedure DEFINING_PROGRAM_UNIT_NAME PARAMETER_PROFILE
...@@ -445,13 +448,19 @@ package body Ch6 is ...@@ -445,13 +448,19 @@ package body Ch6 is
end if; end if;
end if; end if;
-- Subprogram declaration ended by aspect specifications
if Aspect_Specifications_Present then
goto Subprogram_Declaration;
-- Deal with case of semicolon ending a subprogram declaration -- Deal with case of semicolon ending a subprogram declaration
if Token = Tok_Semicolon then elsif Token = Tok_Semicolon then
if not Pf_Flags.Decl then if not Pf_Flags.Decl then
T_Is; T_Is;
end if; end if;
Save_Scan_State (Scan_State);
Scan; -- past semicolon Scan; -- past semicolon
-- If semicolon is immediately followed by IS, then ignore the -- If semicolon is immediately followed by IS, then ignore the
...@@ -476,6 +485,7 @@ package body Ch6 is ...@@ -476,6 +485,7 @@ package body Ch6 is
goto Subprogram_Body; goto Subprogram_Body;
else else
Restore_Scan_State (Scan_State);
goto Subprogram_Declaration; goto Subprogram_Declaration;
end if; end if;
...@@ -544,7 +554,6 @@ package body Ch6 is ...@@ -544,7 +554,6 @@ package body Ch6 is
Set_Null_Present (Specification_Node); Set_Null_Present (Specification_Node);
end if; end if;
TF_Semicolon;
goto Subprogram_Declaration; goto Subprogram_Declaration;
-- Check for IS NEW with Formal_Part present and handle nicely -- Check for IS NEW with Formal_Part present and handle nicely
...@@ -572,6 +581,11 @@ package body Ch6 is ...@@ -572,6 +581,11 @@ package body Ch6 is
goto Subprogram_Body; goto Subprogram_Body;
end if; end if;
-- Aspect specifications present
elsif Aspect_Specifications_Present then
goto Subprogram_Declaration;
-- Here we have a missing IS or missing semicolon, we always guess -- Here we have a missing IS or missing semicolon, we always guess
-- a missing semicolon, since we are pretty good at fixing up a -- a missing semicolon, since we are pretty good at fixing up a
-- semicolon which should really be an IS -- semicolon which should really be an IS
...@@ -770,6 +784,7 @@ package body Ch6 is ...@@ -770,6 +784,7 @@ package body Ch6 is
Decl_Node := Decl_Node :=
New_Node (N_Subprogram_Declaration, Sloc (Specification_Node)); New_Node (N_Subprogram_Declaration, Sloc (Specification_Node));
Set_Specification (Decl_Node, Specification_Node); Set_Specification (Decl_Node, Specification_Node);
P_Aspect_Specifications (Decl_Node);
-- If this is a context in which a subprogram body is permitted, -- If this is a context in which a subprogram body is permitted,
-- set active SIS entry in case (see section titled "Handling -- set active SIS entry in case (see section titled "Handling
......
...@@ -37,7 +37,9 @@ package body Ch7 is ...@@ -37,7 +37,9 @@ package body Ch7 is
-- This routine scans out a package declaration, package body, or a -- This routine scans out a package declaration, package body, or a
-- renaming declaration or generic instantiation starting with PACKAGE -- renaming declaration or generic instantiation starting with PACKAGE
-- PACKAGE_DECLARATION ::= PACKAGE_SPECIFICATION; -- PACKAGE_DECLARATION ::=
-- PACKAGE_SPECIFICATION
-- [ASPECT_SPECIFICATIONS];
-- PACKAGE_SPECIFICATION ::= -- PACKAGE_SPECIFICATION ::=
-- package DEFINING_PROGRAM_UNIT_NAME is -- package DEFINING_PROGRAM_UNIT_NAME is
...@@ -59,6 +61,11 @@ package body Ch7 is ...@@ -59,6 +61,11 @@ package body Ch7 is
-- PACKAGE_BODY_STUB ::= -- PACKAGE_BODY_STUB ::=
-- package body DEFINING_IDENTIFIER is separate; -- package body DEFINING_IDENTIFIER is separate;
-- PACKAGE_INSTANTIATION ::=
-- package DEFINING_PROGRAM_UNIT_NAME is
-- new generic_package_NAME [GENERIC_ACTUAL_PART]
-- [ASPECT_SPECIFICATIONS];
-- The value in Pf_Flags indicates which of these possible declarations -- The value in Pf_Flags indicates which of these possible declarations
-- is acceptable to the caller: -- is acceptable to the caller:
...@@ -85,7 +92,10 @@ package body Ch7 is ...@@ -85,7 +92,10 @@ package body Ch7 is
-- Error recovery: cannot raise Error_Resync -- Error recovery: cannot raise Error_Resync
function P_Package (Pf_Flags : Pf_Rec) return Node_Id is function P_Package
(Pf_Flags : Pf_Rec;
Decl : Node_Id := Empty) return Node_Id
is
Package_Node : Node_Id; Package_Node : Node_Id;
Specification_Node : Node_Id; Specification_Node : Node_Id;
Name_Node : Node_Id; Name_Node : Node_Id;
...@@ -185,7 +195,7 @@ package body Ch7 is ...@@ -185,7 +195,7 @@ package body Ch7 is
Set_Name (Package_Node, P_Qualified_Simple_Name); Set_Name (Package_Node, P_Qualified_Simple_Name);
Set_Generic_Associations Set_Generic_Associations
(Package_Node, P_Generic_Actual_Part_Opt); (Package_Node, P_Generic_Actual_Part_Opt);
TF_Semicolon; P_Aspect_Specifications (Package_Node);
Pop_Scope_Stack; Pop_Scope_Stack;
-- Case of package declaration or package specification -- Case of package declaration or package specification
...@@ -239,7 +249,11 @@ package body Ch7 is ...@@ -239,7 +249,11 @@ package body Ch7 is
Discard_Junk_List (P_Sequence_Of_Statements (SS_None)); Discard_Junk_List (P_Sequence_Of_Statements (SS_None));
end if; end if;
End_Statements (Specification_Node); if Nkind (Package_Node) = N_Package_Declaration then
End_Statements (Specification_Node, Package_Node);
else
End_Statements (Specification_Node, Decl);
end if;
end if; end if;
return Package_Node; return Package_Node;
......
...@@ -40,23 +40,33 @@ package body Ch9 is ...@@ -40,23 +40,33 @@ package body Ch9 is
function P_Entry_Body_Formal_Part return Node_Id; function P_Entry_Body_Formal_Part return Node_Id;
function P_Entry_Declaration return Node_Id; function P_Entry_Declaration return Node_Id;
function P_Entry_Index_Specification return Node_Id; function P_Entry_Index_Specification return Node_Id;
function P_Protected_Definition return Node_Id;
function P_Protected_Operation_Declaration_Opt return Node_Id; function P_Protected_Operation_Declaration_Opt return Node_Id;
function P_Protected_Operation_Items return List_Id; function P_Protected_Operation_Items return List_Id;
function P_Task_Definition return Node_Id;
function P_Task_Items return List_Id; function P_Task_Items return List_Id;
function P_Protected_Definition (Decl : Node_Id) return Node_Id;
-- Parses protected definition and following aspect specifications if
-- present. The argument is the declaration node to which the aspect
-- specifications are to be attached.
function P_Task_Definition (Decl : Node_Id) return Node_Id;
-- Parses task definition and following aspect specifications if present.
-- The argument is the declaration node to which the aspect specifications
-- are to be attached.
----------------------------- -----------------------------
-- 9.1 Task (also 10.1.3) -- -- 9.1 Task (also 10.1.3) --
----------------------------- -----------------------------
-- TASK_TYPE_DECLARATION ::= -- TASK_TYPE_DECLARATION ::=
-- task type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART] -- task type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
-- [is [new INTERFACE_LIST with] TASK_DEFINITION]; -- [is [new INTERFACE_LIST with] TASK_DEFINITION]
-- [ASPECT_SPECIFICATIONS];
-- SINGLE_TASK_DECLARATION ::= -- SINGLE_TASK_DECLARATION ::=
-- task DEFINING_IDENTIFIER -- task DEFINING_IDENTIFIER
-- [is [new INTERFACE_LIST with] TASK_DEFINITION]; -- [is [new INTERFACE_LIST with] TASK_DEFINITION]
-- [ASPECT_SPECIFICATIONS];
-- TASK_BODY ::= -- TASK_BODY ::=
-- task body DEFINING_IDENTIFIER is -- task body DEFINING_IDENTIFIER is
...@@ -143,10 +153,17 @@ package body Ch9 is ...@@ -143,10 +153,17 @@ package body Ch9 is
end if; end if;
end if; end if;
-- If we have aspect definitions present here, then we do not have
-- a task definition present.
if Aspect_Specifications_Present then
P_Aspect_Specifications (Task_Node);
-- Parse optional task definition. Note that P_Task_Definition scans -- Parse optional task definition. Note that P_Task_Definition scans
-- out the semicolon as well as the task definition itself. -- out the semicolon and possible aspect specifications as well as
-- the task definition itself.
if Token = Tok_Semicolon then elsif Token = Tok_Semicolon then
-- A little check, if the next token after semicolon is -- A little check, if the next token after semicolon is
-- Entry, then surely the semicolon should really be IS -- Entry, then surely the semicolon should really be IS
...@@ -156,10 +173,13 @@ package body Ch9 is ...@@ -156,10 +173,13 @@ package body Ch9 is
if Token = Tok_Entry then if Token = Tok_Entry then
Error_Msg_SP -- CODEFIX Error_Msg_SP -- CODEFIX
("|"";"" should be IS"); ("|"";"" should be IS");
Set_Task_Definition (Task_Node, P_Task_Definition); Set_Task_Definition (Task_Node, P_Task_Definition (Task_Node));
else else
Pop_Scope_Stack; -- Remove unused entry Pop_Scope_Stack; -- Remove unused entry
end if; end if;
-- Here we have a task definition
else else
TF_Is; -- must have IS if no semicolon TF_Is; -- must have IS if no semicolon
...@@ -194,7 +214,7 @@ package body Ch9 is ...@@ -194,7 +214,7 @@ package body Ch9 is
end if; end if;
end if; end if;
Set_Task_Definition (Task_Node, P_Task_Definition); Set_Task_Definition (Task_Node, P_Task_Definition (Task_Node));
end if; end if;
return Task_Node; return Task_Node;
...@@ -233,7 +253,7 @@ package body Ch9 is ...@@ -233,7 +253,7 @@ package body Ch9 is
-- Error recovery: cannot raise Error_Resync -- Error recovery: cannot raise Error_Resync
function P_Task_Definition return Node_Id is function P_Task_Definition (Decl : Node_Id) return Node_Id is
Def_Node : Node_Id; Def_Node : Node_Id;
begin begin
...@@ -253,7 +273,7 @@ package body Ch9 is ...@@ -253,7 +273,7 @@ package body Ch9 is
end loop; end loop;
end if; end if;
End_Statements (Def_Node); End_Statements (Def_Node, Decl);
return Def_Node; return Def_Node;
end P_Task_Definition; end P_Task_Definition;
...@@ -347,11 +367,13 @@ package body Ch9 is ...@@ -347,11 +367,13 @@ package body Ch9 is
-- PROTECTED_TYPE_DECLARATION ::= -- PROTECTED_TYPE_DECLARATION ::=
-- protected type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART] -- protected type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
-- is [new INTERFACE_LIST with] PROTECTED_DEFINITION; -- is [new INTERFACE_LIST with] PROTECTED_DEFINITION
-- [ASPECT_SPECIFICATIONS];
-- SINGLE_PROTECTED_DECLARATION ::= -- SINGLE_PROTECTED_DECLARATION ::=
-- protected DEFINING_IDENTIFIER -- protected DEFINING_IDENTIFIER
-- is [new INTERFACE_LIST with] PROTECTED_DEFINITION; -- is [new INTERFACE_LIST with] PROTECTED_DEFINITION;
-- [ASPECT_SPECIFICATIONS];
-- PROTECTED_BODY ::= -- PROTECTED_BODY ::=
-- protected body DEFINING_IDENTIFIER is -- protected body DEFINING_IDENTIFIER is
...@@ -464,8 +486,8 @@ package body Ch9 is ...@@ -464,8 +486,8 @@ package body Ch9 is
End_Label => Empty)); End_Label => Empty));
SIS_Entry_Active := False; SIS_Entry_Active := False;
End_Statements (Protected_Definition (Protected_Node)); End_Statements
Scan; -- past semicolon (Protected_Definition (Protected_Node), Protected_Node);
return Protected_Node; return Protected_Node;
end if; end if;
...@@ -503,7 +525,8 @@ package body Ch9 is ...@@ -503,7 +525,8 @@ package body Ch9 is
Scan; -- past WITH Scan; -- past WITH
end if; end if;
Set_Protected_Definition (Protected_Node, P_Protected_Definition); Set_Protected_Definition
(Protected_Node, P_Protected_Definition (Protected_Node));
return Protected_Node; return Protected_Node;
end if; end if;
end P_Protected; end P_Protected;
...@@ -538,7 +561,7 @@ package body Ch9 is ...@@ -538,7 +561,7 @@ package body Ch9 is
-- Error recovery: cannot raise Error_Resync -- Error recovery: cannot raise Error_Resync
function P_Protected_Definition return Node_Id is function P_Protected_Definition (Decl : Node_Id) return Node_Id is
Def_Node : Node_Id; Def_Node : Node_Id;
Item_Node : Node_Id; Item_Node : Node_Id;
...@@ -584,7 +607,7 @@ package body Ch9 is ...@@ -584,7 +607,7 @@ package body Ch9 is
end loop Declaration_Loop; end loop Declaration_Loop;
end loop Private_Loop; end loop Private_Loop;
End_Statements (Def_Node); End_Statements (Def_Node, Decl);
return Def_Node; return Def_Node;
end P_Protected_Definition; end P_Protected_Definition;
......
...@@ -166,7 +166,7 @@ package body Endh is ...@@ -166,7 +166,7 @@ package body Endh is
-- Check_End -- -- Check_End --
--------------- ---------------
function Check_End return Boolean is function Check_End (Decl : Node_Id := Empty) return Boolean is
Name_On_Separate_Line : Boolean; Name_On_Separate_Line : Boolean;
-- Set True if the name on an END line is on a separate source line -- Set True if the name on an END line is on a separate source line
-- from the END. This is highly suspicious, but is allowed. The point -- from the END. This is highly suspicious, but is allowed. The point
...@@ -387,6 +387,15 @@ package body Endh is ...@@ -387,6 +387,15 @@ package body Endh is
end if; end if;
end if; end if;
-- Scan aspect specifications if permitted here
if Aspect_Specifications_Present then
if No (Decl) then
P_Aspect_Specifications (Error);
else
P_Aspect_Specifications (Decl);
end if;
-- Except in case of END RECORD, semicolon must follow. For END -- Except in case of END RECORD, semicolon must follow. For END
-- RECORD, a semicolon does follow, but it is part of a higher level -- RECORD, a semicolon does follow, but it is part of a higher level
-- construct. In any case, a missing semicolon is not serious enough -- construct. In any case, a missing semicolon is not serious enough
...@@ -394,7 +403,7 @@ package body Endh is ...@@ -394,7 +403,7 @@ package body Endh is
-- are dealing with (i.e. to be suspicious that it is not in fact -- are dealing with (i.e. to be suspicious that it is not in fact
-- the END statement we are looking for!) -- the END statement we are looking for!)
if End_Type /= E_Record then elsif End_Type /= E_Record then
if Token = Tok_Semicolon then if Token = Tok_Semicolon then
T_Semicolon; T_Semicolon;
...@@ -644,13 +653,15 @@ package body Endh is ...@@ -644,13 +653,15 @@ package body Endh is
-- Error recovery: cannot raise Error_Resync; -- Error recovery: cannot raise Error_Resync;
procedure End_Statements (Parent : Node_Id := Empty) is procedure End_Statements
(Parent : Node_Id := Empty;
Decl : Node_Id := Empty) is
begin begin
-- This loop runs more than once in the case where Check_End rejects -- This loop runs more than once in the case where Check_End rejects
-- the END sequence, as indicated by Check_End returning False. -- the END sequence, as indicated by Check_End returning False.
loop loop
if Check_End then if Check_End (Decl) then
if Present (Parent) then if Present (Parent) then
Set_End_Label (Parent, End_Labl); Set_End_Label (Parent, End_Labl);
end if; end if;
......
...@@ -754,10 +754,14 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is ...@@ -754,10 +754,14 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
------------- -------------
package Ch7 is package Ch7 is
function P_Package (Pf_Flags : Pf_Rec) return Node_Id; function P_Package
(Pf_Flags : Pf_Rec;
Decl : Node_Id := Empty) return Node_Id;
-- Scans out any construct starting with the keyword PACKAGE. The -- Scans out any construct starting with the keyword PACKAGE. The
-- parameter indicates which possible kinds of construct (body, spec, -- parameter indicates which possible kinds of construct (body, spec,
-- instantiation etc.) are permissible in the current context. -- instantiation etc.) are permissible in the current context. Decl
-- is set in the specification case to request that if there are aspect
-- specifications present, they be associated with this declaration.
end Ch7; end Ch7;
------------- -------------
...@@ -854,7 +858,9 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is ...@@ -854,7 +858,9 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
-- the given declaration node, and the list of aspect specifications is -- the given declaration node, and the list of aspect specifications is
-- constructed and associated with this declaration node using a call to -- constructed and associated with this declaration node using a call to
-- Set_Aspect_Specifications. If no WITH keyword is present, then this -- Set_Aspect_Specifications. If no WITH keyword is present, then this
-- call has no effect other than scanning out the semicolon. -- call has no effect other than scanning out the semicolon. If Decl is
-- Error on entry, any scanned aspect specifications are ignored and a
-- message is output saying aspect specifications not permitted here.
function P_Code_Statement (Subtype_Mark : Node_Id) return Node_Id; function P_Code_Statement (Subtype_Mark : Node_Id) return Node_Id;
-- Function to parse a code statement. The caller has scanned out -- Function to parse a code statement. The caller has scanned out
...@@ -880,7 +886,7 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is ...@@ -880,7 +886,7 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
-- Routines for handling end lines, including scope recovery -- Routines for handling end lines, including scope recovery
package Endh is package Endh is
function Check_End return Boolean; function Check_End (Decl : Node_Id := Empty) return Boolean;
-- Called when an end sequence is required. In the absence of an error -- Called when an end sequence is required. In the absence of an error
-- situation, Token contains Tok_End on entry, but in a missing end -- situation, Token contains Tok_End on entry, but in a missing end
-- case, this may not be the case. Pop_End_Context is used to determine -- case, this may not be the case. Pop_End_Context is used to determine
...@@ -891,6 +897,10 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is ...@@ -891,6 +897,10 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
-- Skip_And_Reject). Note that the END sequence includes a semicolon, -- Skip_And_Reject). Note that the END sequence includes a semicolon,
-- except in the case of END RECORD, where a semicolon follows the END -- except in the case of END RECORD, where a semicolon follows the END
-- RECORD, but is not part of the record type definition itself. -- RECORD, but is not part of the record type definition itself.
--
-- If Decl is non-empty, then aspect specifications are permitted
-- following the end, and Decl is the declaration node with which
-- these aspect specifications are to be associated.
procedure End_Skip; procedure End_Skip;
-- Skip past an end sequence. On entry Token contains Tok_End, and we -- Skip past an end sequence. On entry Token contains Tok_End, and we
...@@ -900,13 +910,19 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is ...@@ -900,13 +910,19 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
-- position after the end sequence. We do not issue any additional -- position after the end sequence. We do not issue any additional
-- error messages while carrying this out. -- error messages while carrying this out.
procedure End_Statements (Parent : Node_Id := Empty); procedure End_Statements
(Parent : Node_Id := Empty;
Decl : Node_Id := Empty);
-- Called when an end is required or expected to terminate a sequence -- Called when an end is required or expected to terminate a sequence
-- of statements. The caller has already made an appropriate entry in -- of statements. The caller has already made an appropriate entry in
-- the Scope.Table to describe the expected form of the end. This can -- the Scope.Table to describe the expected form of the end. This can
-- only be used in cases where the only appropriate terminator is end. -- only be used in cases where the only appropriate terminator is end.
-- If Parent is non-empty, then if a correct END line is encountered, -- If Parent is non-empty, then if a correct END line is encountered,
-- the End_Label field of Parent is set appropriately. -- the End_Label field of Parent is set appropriately.
--
-- If Decl is non-null, then it is a declaration node, and aspect
-- specifications are permitted after the end statement. These aspect
-- specifications, if present, are stored in this declaration node.
end Endh; end Endh;
-------------- --------------
......
...@@ -5371,16 +5371,37 @@ package body Sem_Attr is ...@@ -5371,16 +5371,37 @@ package body Sem_Attr is
-- P; -- P;
-- end; -- end;
-- which shouold print 64 rather than 32. The exclusion of non-source -- which should print 64 rather than 32. The exclusion of non-source
-- constructs from this test comes from some internal usage in packed -- constructs from this test comes from some internal usage in packed
-- arrays, which otherwise fails, could use more analysis perhaps??? -- arrays, which otherwise fails, could use more analysis perhaps???
if In_Spec_Expression declare
and then Comes_From_Source (N) function Within_Aspect (N : Node_Id) return Boolean;
and then not (Is_Entity_Name (P) and then Is_Frozen (Entity (P))) -- True if within aspect expression. Giant kludge, do this test only
then -- within an aspect, since doing it more widely, even though clearly
return; -- correct, causes regressions notably in GA19-001 ???
end if;
function Within_Aspect (N : Node_Id) return Boolean
is
begin
if No (Parent (N)) then
return False;
elsif Nkind (N) = N_Aspect_Specification then
return True;
else
return Within_Aspect (Parent (N));
end if;
end Within_Aspect;
begin
if In_Spec_Expression
and then Comes_From_Source (N)
and then not (Is_Entity_Name (P) and then Is_Frozen (Entity (P)))
and then Within_Aspect (N)
then
return;
end if;
end;
-- Acquire first two expressions (at the moment, no attributes take more -- Acquire first two expressions (at the moment, no attributes take more
-- than two expressions in any case). -- than two expressions in any case).
......
...@@ -5768,6 +5768,14 @@ package body Sem_Ch12 is ...@@ -5768,6 +5768,14 @@ package body Sem_Ch12 is
New_N := New_Copy (N); New_N := New_Copy (N);
-- Copy aspects if present
if Has_Aspects (N) then
Set_Has_Aspects (New_N, False);
Set_Aspect_Specifications
(New_N, Copy_Generic_List (Aspect_Specifications (N), Parent_Id));
end if;
if Instantiating then if Instantiating then
Adjust_Instantiation_Sloc (New_N, S_Adjustment); Adjust_Instantiation_Sloc (New_N, S_Adjustment);
end if; end if;
......
...@@ -64,7 +64,9 @@ package Sem_Ch12 is ...@@ -64,7 +64,9 @@ package Sem_Ch12 is
-- repeatedly: once to produce a copy on which semantic analysis of -- repeatedly: once to produce a copy on which semantic analysis of
-- the generic is performed, and once for each instantiation. The tree -- the generic is performed, and once for each instantiation. The tree
-- being copied is not semantically analyzed, except that references to -- being copied is not semantically analyzed, except that references to
-- global entities are marked on terminal nodes. -- global entities are marked on terminal nodes. Note that this function
-- copies any aspect specifications from the input node N to the returned
-- node, as well as the setting of the Has_Aspects flag.
function Get_Instance_Of (A : Entity_Id) return Entity_Id; function Get_Instance_Of (A : Entity_Id) return Entity_Id;
-- Retrieve actual associated with given generic parameter. -- Retrieve actual associated with given generic parameter.
......
...@@ -4150,10 +4150,16 @@ package body Sem_Ch3 is ...@@ -4150,10 +4150,16 @@ package body Sem_Ch3 is
end if; end if;
end if; end if;
-- Make sure that generic actual types are properly frozen -- Make sure that generic actual types are properly frozen The subtype
-- is marked as a generic actual type when the enclosing instance is
-- analyzed, so here we identify the subtype from the tree structure.
if Expander_Active if Expander_Active
and then Is_Generic_Actual_Type (Id) and then Is_Generic_Actual_Type (Id)
and then In_Instance
and then not Comes_From_Source (N)
and then Nkind (Subtype_Indication (N)) /= N_Subtype_Indication
and then Is_Frozen (T)
then then
Insert_Actions (N, Freeze_Entity (Id, N)); Insert_Actions (N, Freeze_Entity (Id, N));
end if; end if;
......
...@@ -2737,6 +2737,27 @@ package body Sem_Ch6 is ...@@ -2737,6 +2737,27 @@ package body Sem_Ch6 is
Set_Defining_Identifier (Form, Set_Defining_Identifier (Form,
Make_Defining_Identifier (Loc, Make_Defining_Identifier (Loc,
Chars (Defining_Identifier (Form)))); Chars (Defining_Identifier (Form))));
-- Resolve the types of the formals now, because the freeze point
-- may appear in a different context, e.g. an instantiation.
if Nkind (Parameter_Type (Form)) /= N_Access_Definition then
Find_Type (Parameter_Type (Form));
elsif
No (Access_To_Subprogram_Definition (Parameter_Type (Form)))
then
Find_Type (Subtype_Mark (Parameter_Type (Form)));
else
-- the case of a null procedure with a formal that is an
-- access_to_subprogram type, and that is used as an actual
-- in an instantiation is left to the enthusiastic reader.
null;
end if;
Next (Form); Next (Form);
end loop; end loop;
......
...@@ -1691,6 +1691,7 @@ package body Sem_Ch9 is ...@@ -1691,6 +1691,7 @@ package body Sem_Ch9 is
Defining_Identifier => O_Name, Defining_Identifier => O_Name,
Object_Definition => Make_Identifier (Loc, Chars (T))); Object_Definition => Make_Identifier (Loc, Chars (T)));
Move_Aspects (N, O_Decl);
Rewrite (N, T_Decl); Rewrite (N, T_Decl);
Insert_After (N, O_Decl); Insert_After (N, O_Decl);
Mark_Rewrite_Insertion (O_Decl); Mark_Rewrite_Insertion (O_Decl);
...@@ -1749,13 +1750,15 @@ package body Sem_Ch9 is ...@@ -1749,13 +1750,15 @@ package body Sem_Ch9 is
-- entity is the new object declaration. The single_task_declaration -- entity is the new object declaration. The single_task_declaration
-- is not used further in semantics or code generation, but is scanned -- is not used further in semantics or code generation, but is scanned
-- when generating debug information, and therefore needs the updated -- when generating debug information, and therefore needs the updated
-- Sloc information for the entity (see Sprint). -- Sloc information for the entity (see Sprint). Aspect specifications
-- are moved from the single task node to the object declaration node.
O_Decl := O_Decl :=
Make_Object_Declaration (Loc, Make_Object_Declaration (Loc,
Defining_Identifier => O_Name, Defining_Identifier => O_Name,
Object_Definition => Make_Identifier (Loc, Chars (T))); Object_Definition => Make_Identifier (Loc, Chars (T)));
Move_Aspects (N, O_Decl);
Rewrite (N, T_Decl); Rewrite (N, T_Decl);
Insert_After (N, O_Decl); Insert_After (N, O_Decl);
Mark_Rewrite_Insertion (O_Decl); Mark_Rewrite_Insertion (O_Decl);
......
...@@ -2120,7 +2120,9 @@ package Sinfo is ...@@ -2120,7 +2120,9 @@ package Sinfo is
-- FULL_TYPE_DECLARATION ::= -- FULL_TYPE_DECLARATION ::=
-- type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART] -- type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
-- is TYPE_DEFINITION; -- is TYPE_DEFINITION
-- [ASPECT_SPECIFICATIONS];
-- | TASK_TYPE_DECLARATION -- | TASK_TYPE_DECLARATION
-- | PROTECTED_TYPE_DECLARATION -- | PROTECTED_TYPE_DECLARATION
...@@ -2227,11 +2229,14 @@ package Sinfo is ...@@ -2227,11 +2229,14 @@ package Sinfo is
-- OBJECT_DECLARATION ::= -- OBJECT_DECLARATION ::=
-- DEFINING_IDENTIFIER_LIST : [aliased] [constant] -- DEFINING_IDENTIFIER_LIST : [aliased] [constant]
-- [NULL_EXCLUSION] SUBTYPE_INDICATION [:= EXPRESSION]; -- [NULL_EXCLUSION] SUBTYPE_INDICATION [:= EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- | DEFINING_IDENTIFIER_LIST : [aliased] [constant] -- | DEFINING_IDENTIFIER_LIST : [aliased] [constant]
-- ACCESS_DEFINITION [:= EXPRESSION]; -- ACCESS_DEFINITION [:= EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- | DEFINING_IDENTIFIER_LIST : [aliased] [constant] -- | DEFINING_IDENTIFIER_LIST : [aliased] [constant]
-- ARRAY_TYPE_DEFINITION [:= EXPRESSION]; -- ARRAY_TYPE_DEFINITION [:= EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- | SINGLE_TASK_DECLARATION -- | SINGLE_TASK_DECLARATION
-- | SINGLE_PROTECTED_DECLARATION -- | SINGLE_PROTECTED_DECLARATION
...@@ -2841,7 +2846,8 @@ package Sinfo is ...@@ -2841,7 +2846,8 @@ package Sinfo is
-- COMPONENT_DECLARATION ::= -- COMPONENT_DECLARATION ::=
-- DEFINING_IDENTIFIER_LIST : COMPONENT_DEFINITION -- DEFINING_IDENTIFIER_LIST : COMPONENT_DEFINITION
-- [:= DEFAULT_EXPRESSION]; -- [:= DEFAULT_EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- Note: although the syntax does not permit a component definition to -- Note: although the syntax does not permit a component definition to
-- be an anonymous array (and the parser will diagnose such an attempt -- be an anonymous array (and the parser will diagnose such an attempt
...@@ -4209,7 +4215,9 @@ package Sinfo is ...@@ -4209,7 +4215,9 @@ package Sinfo is
-- 6.1 Subprogram Declaration -- -- 6.1 Subprogram Declaration --
--------------------------------- ---------------------------------
-- SUBPROGRAM_DECLARATION ::= SUBPROGRAM_SPECIFICATION; -- SUBPROGRAM_DECLARATION ::=
-- SUBPROGRAM_SPECIFICATION
-- [ASPECT_SPECIFICATIONS];
-- N_Subprogram_Declaration -- N_Subprogram_Declaration
-- Sloc points to FUNCTION or PROCEDURE -- Sloc points to FUNCTION or PROCEDURE
...@@ -4223,7 +4231,8 @@ package Sinfo is ...@@ -4223,7 +4231,8 @@ package Sinfo is
------------------------------------------ ------------------------------------------
-- ABSTRACT_SUBPROGRAM_DECLARATION ::= -- ABSTRACT_SUBPROGRAM_DECLARATION ::=
-- SUBPROGRAM_SPECIFICATION is abstract; -- SUBPROGRAM_SPECIFICATION is abstract
-- [ASPECT_SPECIFICATIONS];
-- N_Abstract_Subprogram_Declaration -- N_Abstract_Subprogram_Declaration
-- Sloc points to ABSTRACT -- Sloc points to ABSTRACT
...@@ -4640,7 +4649,9 @@ package Sinfo is ...@@ -4640,7 +4649,9 @@ package Sinfo is
-- 7.1 Package Declaration -- -- 7.1 Package Declaration --
------------------------------ ------------------------------
-- PACKAGE_DECLARATION ::= PACKAGE_SPECIFICATION; -- PACKAGE_DECLARATION ::=
-- PACKAGE_SPECIFICATION
-- [ASPECT_SPECIFICATIONS];
-- Note: the activation chain entity for a package spec is used for -- Note: the activation chain entity for a package spec is used for
-- all tasks declared in the package spec, or in the package body. -- all tasks declared in the package spec, or in the package body.
...@@ -4889,7 +4900,8 @@ package Sinfo is ...@@ -4889,7 +4900,8 @@ package Sinfo is
-- TASK_TYPE_DECLARATION ::= -- TASK_TYPE_DECLARATION ::=
-- task type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART] -- task type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
-- [is [new INTERFACE_LIST with] TASK_DEFINITION]; -- [is [new INTERFACE_LIST with] TASK_DEFINITION]
-- [ASPECT_SPECIFICATIONS];
-- N_Task_Type_Declaration -- N_Task_Type_Declaration
-- Sloc points to TASK -- Sloc points to TASK
...@@ -4906,7 +4918,8 @@ package Sinfo is ...@@ -4906,7 +4918,8 @@ package Sinfo is
-- SINGLE_TASK_DECLARATION ::= -- SINGLE_TASK_DECLARATION ::=
-- task DEFINING_IDENTIFIER -- task DEFINING_IDENTIFIER
-- [is [new INTERFACE_LIST with] TASK_DEFINITION]; -- [is [new INTERFACE_LIST with] TASK_DEFINITION]
-- [ASPECT_SPECIFICATIONS];
-- N_Single_Task_Declaration -- N_Single_Task_Declaration
-- Sloc points to TASK -- Sloc points to TASK
...@@ -4973,7 +4986,8 @@ package Sinfo is ...@@ -4973,7 +4986,8 @@ package Sinfo is
-- PROTECTED_TYPE_DECLARATION ::= -- PROTECTED_TYPE_DECLARATION ::=
-- protected type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART] -- protected type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
-- is [new INTERFACE_LIST with] PROTECTED_DEFINITION; -- is [new INTERFACE_LIST with] PROTECTED_DEFINITION
-- {ASPECT_SPECIFICATIONS];
-- Note: protected type declarations are not permitted in Ada 83 mode -- Note: protected type declarations are not permitted in Ada 83 mode
...@@ -4992,7 +5006,8 @@ package Sinfo is ...@@ -4992,7 +5006,8 @@ package Sinfo is
-- SINGLE_PROTECTED_DECLARATION ::= -- SINGLE_PROTECTED_DECLARATION ::=
-- protected DEFINING_IDENTIFIER -- protected DEFINING_IDENTIFIER
-- is [new INTERFACE_LIST with] PROTECTED_DEFINITION; -- is [new INTERFACE_LIST with] PROTECTED_DEFINITION
-- [ASPECT_SPECIFICATIONS];
-- Note: single protected declarations are not allowed in Ada 83 mode -- Note: single protected declarations are not allowed in Ada 83 mode
...@@ -5733,7 +5748,8 @@ package Sinfo is ...@@ -5733,7 +5748,8 @@ package Sinfo is
-- 11.1 Exception Declaration -- -- 11.1 Exception Declaration --
--------------------------------- ---------------------------------
-- EXCEPTION_DECLARATION ::= DEFINING_IDENTIFIER_LIST : exception; -- EXCEPTION_DECLARATION ::= DEFINING_IDENTIFIER_LIST : exception
-- [ASPECT_SPECIFICATIONS];
-- For consistency with object declarations etc., the parser converts -- For consistency with object declarations etc., the parser converts
-- the case of multiple identifiers being declared to a series of -- the case of multiple identifiers being declared to a series of
...@@ -5902,7 +5918,8 @@ package Sinfo is ...@@ -5902,7 +5918,8 @@ package Sinfo is
--------------------------------------- ---------------------------------------
-- GENERIC_PACKAGE_DECLARATION ::= -- GENERIC_PACKAGE_DECLARATION ::=
-- GENERIC_FORMAL_PART PACKAGE_SPECIFICATION; -- GENERIC_FORMAL_PART PACKAGE_SPECIFICATION
-- [ASPECT_SPECIFICATIONS];
-- Note: when we do generics right, the Activation_Chain_Entity entry -- Note: when we do generics right, the Activation_Chain_Entity entry
-- for this node can be removed (since the expander won't see generic -- for this node can be removed (since the expander won't see generic
...@@ -5941,13 +5958,16 @@ package Sinfo is ...@@ -5941,13 +5958,16 @@ package Sinfo is
-- GENERIC_INSTANTIATION ::= -- GENERIC_INSTANTIATION ::=
-- package DEFINING_PROGRAM_UNIT_NAME is -- package DEFINING_PROGRAM_UNIT_NAME is
-- new generic_package_NAME [GENERIC_ACTUAL_PART]; -- new generic_package_NAME [GENERIC_ACTUAL_PART]
-- [ASPECT_SPECIFICATIONS];
-- | [[not] overriding] -- | [[not] overriding]
-- procedure DEFINING_PROGRAM_UNIT_NAME is -- procedure DEFINING_PROGRAM_UNIT_NAME is
-- new generic_procedure_NAME [GENERIC_ACTUAL_PART]; -- new generic_procedure_NAME [GENERIC_ACTUAL_PART]
-- [ASPECT_SPECIFICATIONS];
-- | [[not] overriding] -- | [[not] overriding]
-- function DEFINING_DESIGNATOR is -- function DEFINING_DESIGNATOR is
-- new generic_function_NAME [GENERIC_ACTUAL_PART]; -- new generic_function_NAME [GENERIC_ACTUAL_PART]
-- [ASPECT_SPECIFICATIONS];
-- N_Package_Instantiation -- N_Package_Instantiation
-- Sloc points to PACKAGE -- Sloc points to PACKAGE
...@@ -6031,9 +6051,11 @@ package Sinfo is ...@@ -6031,9 +6051,11 @@ package Sinfo is
-- FORMAL_OBJECT_DECLARATION ::= -- FORMAL_OBJECT_DECLARATION ::=
-- DEFINING_IDENTIFIER_LIST : -- DEFINING_IDENTIFIER_LIST :
-- MODE [NULL_EXCLUSION] SUBTYPE_MARK [:= DEFAULT_EXPRESSION]; -- MODE [NULL_EXCLUSION] SUBTYPE_MARK [:= DEFAULT_EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- | DEFINING_IDENTIFIER_LIST : -- | DEFINING_IDENTIFIER_LIST :
-- MODE ACCESS_DEFINITION [:= DEFAULT_EXPRESSION]; -- MODE ACCESS_DEFINITION [:= DEFAULT_EXPRESSION]
-- [ASPECT_SPECIFICATIONS];
-- Although the syntax allows multiple identifiers in the list, the -- Although the syntax allows multiple identifiers in the list, the
-- semantics is as though successive declarations were given with -- semantics is as though successive declarations were given with
...@@ -6061,7 +6083,8 @@ package Sinfo is ...@@ -6061,7 +6083,8 @@ package Sinfo is
-- FORMAL_TYPE_DECLARATION ::= -- FORMAL_TYPE_DECLARATION ::=
-- type DEFINING_IDENTIFIER [DISCRIMINANT_PART] -- type DEFINING_IDENTIFIER [DISCRIMINANT_PART]
-- is FORMAL_TYPE_DEFINITION; -- is FORMAL_TYPE_DEFINITION
-- [ASPECT_SPECIFICATIONS];
-- N_Formal_Type_Declaration -- N_Formal_Type_Declaration
-- Sloc points to TYPE -- Sloc points to TYPE
...@@ -6208,7 +6231,8 @@ package Sinfo is ...@@ -6208,7 +6231,8 @@ package Sinfo is
-------------------------------------------------- --------------------------------------------------
-- FORMAL_CONCRETE_SUBPROGRAM_DECLARATION ::= -- FORMAL_CONCRETE_SUBPROGRAM_DECLARATION ::=
-- with SUBPROGRAM_SPECIFICATION [is SUBPROGRAM_DEFAULT]; -- with SUBPROGRAM_SPECIFICATION [is SUBPROGRAM_DEFAULT]
-- [ASPECT_SPECIFICATIONS];
-- N_Formal_Concrete_Subprogram_Declaration -- N_Formal_Concrete_Subprogram_Declaration
-- Sloc points to WITH -- Sloc points to WITH
...@@ -6224,7 +6248,8 @@ package Sinfo is ...@@ -6224,7 +6248,8 @@ package Sinfo is
-------------------------------------------------- --------------------------------------------------
-- FORMAL_ABSTRACT_SUBPROGRAM_DECLARATION ::= -- FORMAL_ABSTRACT_SUBPROGRAM_DECLARATION ::=
-- with SUBPROGRAM_SPECIFICATION is abstract [SUBPROGRAM_DEFAULT]; -- with SUBPROGRAM_SPECIFICATION is abstract [SUBPROGRAM_DEFAULT]
-- [ASPECT_SPECIFICATIONS];
-- N_Formal_Abstract_Subprogram_Declaration -- N_Formal_Abstract_Subprogram_Declaration
-- Sloc points to WITH -- Sloc points to WITH
...@@ -6258,7 +6283,8 @@ package Sinfo is ...@@ -6258,7 +6283,8 @@ package Sinfo is
-- FORMAL_PACKAGE_DECLARATION ::= -- FORMAL_PACKAGE_DECLARATION ::=
-- with package DEFINING_IDENTIFIER -- with package DEFINING_IDENTIFIER
-- is new generic_package_NAME FORMAL_PACKAGE_ACTUAL_PART; -- is new generic_package_NAME FORMAL_PACKAGE_ACTUAL_PART
-- [ASPECT_SPECIFICATIONS];
-- Note: formal package declarations not allowed in Ada 83 mode -- Note: formal package declarations not allowed in Ada 83 mode
...@@ -6384,7 +6410,7 @@ package Sinfo is ...@@ -6384,7 +6410,7 @@ package Sinfo is
-- entry in the list of aspects. So we use this grammar instead: -- entry in the list of aspects. So we use this grammar instead:
-- ASPECT_SPECIFICATIONS ::= -- ASPECT_SPECIFICATIONS ::=
-- with ASPECT_SPECIFICATION {, ASPECT_SPECIFICATION}; -- with ASPECT_SPECIFICATION {, ASPECT_SPECIFICATION}
-- ASPECT_SPECIFICATION => -- ASPECT_SPECIFICATION =>
-- ASPECT_MARK [=> ASPECT_DEFINITION] -- ASPECT_MARK [=> ASPECT_DEFINITION]
......
...@@ -279,7 +279,7 @@ begin ...@@ -279,7 +279,7 @@ begin
-- Line for -gnatn switch -- Line for -gnatn switch
Write_Switch_Char ("n"); Write_Switch_Char ("n");
Write_Line ("Inlining of subprograms (apply pragma Inline across units)"); Write_Line ("Enable pragma Inline (both within and across units)");
-- Line for -gnatN switch -- Line for -gnatN switch
......
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