This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch allows the compiler to parse and analyze aspect specifications that apply to package bodies, protected bodies, task bodies, [generic] renaming declarations, and body stubs. ------------ -- Source -- ------------ -- bodies.adb package body Bodies with Warnings => On is protected body Prot_Typ with Warnings => On is entry E when True is begin null; end E; end Prot_Typ; task body Task_Typ with Warnings => On is begin accept E; end Task_Typ; end Bodies; -- bodies.ads package Bodies is protected type Prot_Typ is entry E; end Prot_Typ; task type Task_Typ is entry E; end Task_Typ; end Bodies; -- declarations.ads package Declarations is -- Entry declaration task type Task_Typ is entry Task_Entry with Warnings => On; end Task_Typ; -- Exception declaration Exc : exception with Warnings => On; -- Object declaration Obj_1 : Integer with Warnings => On; Obj_2 : Integer := 123 with Warnings => On; Obj_3 : aliased Integer with Warnings => On; Obj_4 : aliased constant Integer := 123 with Warnings => On; Obj_5 : access Integer := null with Warnings => On; Obj_6 : not null access Integer := Obj_3'Access with Warnings => On; type Array_Typ is array (Integer range 1 .. 10) of Boolean; Obj_7 : Array_Typ := (others => False) with Warnings => On; -- Private extension declaration type Root is tagged null record; type Priv_Ext is new Root with private with Warnings => On; -- Private type declaration type Priv_Typ is private with Warnings => On; private type Priv_Ext is new Root with null record; type Priv_Typ is null record; end Declarations; -- expressions.ads package Expressions is -- Expression function function Func (Flag : Boolean) return Integer is (if Flag then 123 else 456) with Warnings => On; end Expressions; -- generics.ads package Generics is generic type Any is private; function Gen_Func return Any with Warnings => On; generic type Any is private; package Gen_Pack is end Gen_Pack; generic type Any is private; procedure Gen_Proc with Warnings => On; end Generics; -- instances.ads with Generics; use Generics; package Instances is -- Generic function instantiation function Func_Inst is new Gen_Func (Integer) with Warnings => On; -- Generic package instantiation package Pack_Inst is new Gen_Pack (Integer) with Warnings => On; -- Generic procedure instantiation procedure Proc_Inst is new Gen_Proc (Integer) with Warnings => On; end Instances; -- renamings.ads with Declarations; use Declarations; with Generics; use Generics; package Renamings is -- Exception renaming Exc_Ren : exception renames Exc with Warnings => On; -- Generic renaming declaration generic function Gen_Func_Ren renames Gen_Func with Warnings => On; generic package Gen_Pack_Ren renames Gen_Pack with Warnings => On; generic procedure Gen_Proc_Ren renames Gen_Proc with Warnings => On; -- Object renaming declaration Obj : aliased Integer; Obj_Ren : Integer renames Obj with Warnings => On; Obj_Ptr : not null access Integer := Obj'Access; Obj_Ptr_Ren_1 : access Integer renames Obj_Ptr with Warnings => On; Obj_Ptr_Ren_2 : not null access Integer renames Obj_Ptr with Warnings => On; -- Package renaming declaration package Decl_Ren renames Declarations with Warnings => On; -- Subprogram renaming declaration function Func return Integer; procedure Proc; function Func_Ren return Integer renames Func with Warnings => On; procedure Proc_ren renames Proc with Warnings => On; end Renamings; -- stubs.adb package body Stubs is -- Package stub package body Pack is separate with Warnings => On; -- Protected stub protected body Prot_Typ is separate with Warnings => On; -- Subprogram stub function Func return Integer is separate with Warnings => On; procedure Proc is separate with Warnings => On; -- Task stub task body Task_Typ is separate with Warnings => On; end Stubs; -- stubs.ads package Stubs is package Pack is procedure Dummy; end Pack; protected type Prot_Typ is entry E; end Prot_Typ; function Func return Integer; procedure Proc; task type Task_Typ is entry E; end Task_Typ; end Stubs; -- stubs-func.adb separate (Stubs) function Func return Integer is begin return 0; end Func; -- stubs-pack.adb separate (Stubs) package body Pack is procedure Dummy is begin null; end Dummy; end Pack; -- stubs-proc.adb separate (Stubs) procedure Proc is begin null; end Proc; -- stubs-prot_typ.adb separate (Stubs) protected body Prot_Typ is entry E when True is begin null; end E; end Prot_Typ; -- stubs-task_typ.adb separate (Stubs) task body Task_Typ is begin accept E; end Task_Typ; ---------------------------- -- Compilation and output -- ---------------------------- $ gcc -c -gnat12 bodies.adb $ gcc -c -gnatc -gnat12 declarations.ads $ gcc -c -gnatc -gnat12 expressions.ads $ gcc -c -gnatc -gnat12 instances.ads $ gcc -c -gnatc -gnat12 renamings.ads $ gcc -c -gnat12 stubs.adb bodies.adb:2:04: warning: user-defined aspects on protected bodies are not supported bodies.adb:6:04: warning: user-defined aspects on task bodies are not supported stubs-prot_typ.adb:3:01: warning: user-defined aspects on protected bodies are not supported stubs-task_typ.adb:3:01: warning: user-defined aspects on task bodies are not supported Tested on x86_64-pc-linux-gnu, committed on trunk 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.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |