diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-10 15:05:40 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-10 15:05:40 +0000 |
commit | f55ce1694e4f99105ae340c55ce4b591e2a9b59c (patch) | |
tree | 054f0d78e3bf4bb0e53238efe06d4c199c493e06 /gcc/ada/par-ch9.adb | |
parent | a5109493ef83c6795389171db07e07cf5da11f85 (diff) | |
download | gcc-f55ce1694e4f99105ae340c55ce4b591e2a9b59c.tar.gz |
2013-09-10 Hristian Kirtchev <kirtchev@adacore.com>
* aspects.adb: Add entries in the Has_Aspect_Specifications_Flag
table for package body and body stubs.
(Move_Or_Merge_Aspects): New routine.
(Remove_Aspects): New routine.
* aspects.ads (Move_Aspects): Update comment on usage.
(Move_Or_Merge_Aspects): New routine.
(Remove_Aspects): New routine.
* par-ch3.adb: Update the grammar of private_type_declaration,
private_extension_declaration, object_renaming_declaration,
and exception_renaming_declaration.
(P_Subprogram): Parse the
aspect specifications that apply to a body stub.
* par-ch6.adb: Update the grammar of subprogram_body_stub and
generic_instantiation.
* par-ch7.adb: Update the grammar of package_declaration,
package_specification, package_body, package_renaming_declaration,
package_body_stub.
(P_Package): Parse the aspect specifications
that apply to a body, a body stub and package renaming.
* par-ch9.adb: Update the grammar of entry_declaration,
protected_body, protected_body_stub, task_body,
and task_body_stub.
(P_Protected): Add local variable
Aspect_Sloc. Add local constant Dummy_Node. Parse the aspect
specifications that apply to a protected body and a protected
body stub.
(P_Task): Add local variable Aspect_Sloc. Add local
constant Dummy_Node. Parse the aspect specifications that apply
to a task body and a task body stub.
* par-ch12.adb: Update the grammar of
generic_renaming_declaration.
(P_Generic): Parse the aspect
specifications that apply to a generic renaming.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not emit
an error when analyzing aspects that apply to a body stub. Such
aspects are relocated to the proper body.
* sem_ch7.adb (Analyze_Package_Body_Helper): Analyze the aspect
specifications that apply to a body.
* sem_ch9.adb (Analyze_Protected_Body): Warn about user-defined
aspects not being supported on protected bodies. Remove the
aspect specifications. (Analyze_Single_Protected_Declaration):
Analyze the aspects that apply to a single protected declaration.
(Analyze_Task_Body): Warn about user-defined aspects not being
supported on task bodies. Remove the aspect specifications.
* sem_ch10.adb: Add with and use clause for Aspects.
(Analyze_Package_Body_Stub): Propagate the aspect specifications
from the stub to the proper body.
* sem_ch13.adb (Analyze_Aspect_Specifications): Insert the
corresponding pragma of an aspect that applies to a body in the
declarations of the body.
* sinfo.ads: Update the gramma of expression_function,
private_type_declaration, private_extension_declaration,
object_renaming_declaration, exception_renaming_declaration,
package_renaming_declaration, subprogram_renaming_declaration,
generic_renaming_declaration, entry_declaration,
subprogram_body_stub, package_body_stub, task_body_stub,
generic_subprogram_declaration.
2013-09-10 Hristian Kirtchev <kirtchev@adacore.com>
* sem_prag.adb (Analyze_Pragma): Add processing
for aspect/pragma SPARK_Mode when it applies to a [library-level]
subprogram or package [body].
2013-09-10 Robert Dewar <dewar@adacore.com>
* gnat_ugn.texi: Document that -gnatc and -gnatR cannot be
given together.
* switch-c.adb (Scan_Front_End_Switches): Give error if both
-gnatR and -gnatc given.
2013-09-10 Robert Dewar <dewar@adacore.com>
* g-table.ads, g-table.adb (For_Each): New generic procedure
(Sort_Table): New generic procedure.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202460 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/par-ch9.adb')
-rw-r--r-- | gcc/ada/par-ch9.adb | 72 |
1 files changed, 62 insertions, 10 deletions
diff --git a/gcc/ada/par-ch9.adb b/gcc/ada/par-ch9.adb index 2de05880b59..e1692c4a11b 100644 --- a/gcc/ada/par-ch9.adb +++ b/gcc/ada/par-ch9.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, 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- -- @@ -61,14 +61,15 @@ package body Ch9 is -- [is [new INTERFACE_LIST with] TASK_DEFINITION]; -- TASK_BODY ::= - -- task body DEFINING_IDENTIFIER is + -- task body DEFINING_IDENTIFIER [ASPECT_SPECIFICATIONS] is -- DECLARATIVE_PART -- begin -- HANDLED_SEQUENCE_OF_STATEMENTS -- end [task_IDENTIFIER] -- TASK_BODY_STUB ::= - -- task body DEFINING_IDENTIFIER is separate; + -- task body DEFINING_IDENTIFIER is separate + -- [ASPECT_SPECIFICATIONS]; -- This routine scans out a task declaration, task body, or task stub @@ -78,9 +79,15 @@ package body Ch9 is -- Error recovery: cannot raise Error_Resync function P_Task return Node_Id is - Name_Node : Node_Id; - Task_Node : Node_Id; - Task_Sloc : Source_Ptr; + Aspect_Sloc : Source_Ptr; + Name_Node : Node_Id; + Task_Node : Node_Id; + Task_Sloc : Source_Ptr; + + Dummy_Node : constant Node_Id := New_Node (N_Task_Body, Token_Ptr); + -- Placeholder node used to hold legal or prematurely declared aspect + -- specifications. Depending on the context, the aspect specifications + -- may be moved to a new node. begin Push_Scope_Stack; @@ -100,6 +107,11 @@ package body Ch9 is Discard_Junk_List (P_Known_Discriminant_Part_Opt); end if; + if Aspect_Specifications_Present then + Aspect_Sloc := Token_Ptr; + P_Aspect_Specifications (Dummy_Node, Semicolon => False); + end if; + TF_Is; -- Task stub @@ -108,6 +120,14 @@ package body Ch9 is Scan; -- past SEPARATE Task_Node := New_Node (N_Task_Body_Stub, Task_Sloc); Set_Defining_Identifier (Task_Node, Name_Node); + + if Has_Aspects (Dummy_Node) then + Error_Msg + ("aspect specifications must come after SEPARATE", + Aspect_Sloc); + end if; + + P_Aspect_Specifications (Task_Node, Semicolon => False); TF_Semicolon; Pop_Scope_Stack; -- remove unused entry @@ -116,6 +136,13 @@ package body Ch9 is else Task_Node := New_Node (N_Task_Body, Task_Sloc); Set_Defining_Identifier (Task_Node, Name_Node); + + -- Move the aspect specifications to the body node + + if Has_Aspects (Dummy_Node) then + Move_Aspects (From => Dummy_Node, To => Task_Node); + end if; + Parse_Decls_Begin_End (Task_Node); end if; @@ -367,12 +394,15 @@ package body Ch9 is -- is [new INTERFACE_LIST with] PROTECTED_DEFINITION; -- PROTECTED_BODY ::= - -- protected body DEFINING_IDENTIFIER is + -- protected body DEFINING_IDENTIFIER + -- [ASPECT_SPECIFICATIONS] + -- is -- {PROTECTED_OPERATION_ITEM} -- end [protected_IDENTIFIER]; -- PROTECTED_BODY_STUB ::= - -- protected body DEFINING_IDENTIFIER is separate; + -- protected body DEFINING_IDENTIFIER is separate + -- [ASPECT_SPECIFICATIONS]; -- This routine scans out a protected declaration, protected body -- or a protected stub. @@ -383,11 +413,17 @@ package body Ch9 is -- Error recovery: cannot raise Error_Resync function P_Protected return Node_Id is + Aspect_Sloc : Source_Ptr; Name_Node : Node_Id; Protected_Node : Node_Id; Protected_Sloc : Source_Ptr; Scan_State : Saved_Scan_State; + Dummy_Node : constant Node_Id := New_Node (N_Protected_Body, Token_Ptr); + -- Placeholder node used to hold legal or prematurely declared aspect + -- specifications. Depending on the context, the aspect specifications + -- may be moved to a new node. + begin Push_Scope_Stack; Scope.Table (Scope.Last).Etyp := E_Name; @@ -405,14 +441,28 @@ package body Ch9 is Discard_Junk_List (P_Known_Discriminant_Part_Opt); end if; + if Aspect_Specifications_Present then + Aspect_Sloc := Token_Ptr; + P_Aspect_Specifications (Dummy_Node, Semicolon => False); + end if; + TF_Is; -- Protected stub if Token = Tok_Separate then Scan; -- past SEPARATE + Protected_Node := New_Node (N_Protected_Body_Stub, Protected_Sloc); Set_Defining_Identifier (Protected_Node, Name_Node); + + if Has_Aspects (Dummy_Node) then + Error_Msg + ("aspect specifications must come after SEPARATE", + Aspect_Sloc); + end if; + + P_Aspect_Specifications (Protected_Node, Semicolon => False); TF_Semicolon; Pop_Scope_Stack; -- remove unused entry @@ -421,6 +471,8 @@ package body Ch9 is else Protected_Node := New_Node (N_Protected_Body, Protected_Sloc); Set_Defining_Identifier (Protected_Node, Name_Node); + + Move_Aspects (From => Dummy_Node, To => Protected_Node); Set_Declarations (Protected_Node, P_Protected_Operation_Items); End_Statements (Protected_Node); end if; @@ -800,8 +852,8 @@ package body Ch9 is -- ENTRY_DECLARATION ::= -- [OVERRIDING_INDICATOR] - -- entry DEFINING_IDENTIFIER [(DISCRETE_SUBTYPE_DEFINITION)] - -- PARAMETER_PROFILE; + -- entry DEFINING_IDENTIFIER + -- [(DISCRETE_SUBTYPE_DEFINITION)] PARAMETER_PROFILE -- [ASPECT_SPECIFICATIONS]; -- The caller has checked that the initial token is ENTRY, NOT or |