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 suppresses warnings concerning potential access-before-elaboration issues when the warnings originate from finalization actions performed within an initialization context. Such warnings seem confusing to users because they are not directly related to source code, but to byproducts of the finalization model in GNAT. Run time ABE checks are still installed in such cases. ------------ -- Source -- ------------ -- pack.ads with Ada.Finalization; use Ada.Finalization; package Pack is type Ctrl is new Controlled with null record; procedure Finalize (Obj : in out Ctrl); procedure Initialize (Obj : in out Ctrl); function Elaborator return Boolean; end Pack; -- pack.adb with Ada.Text_IO; use Ada.Text_IO; package body Pack is procedure Initialize (Obj : in out Ctrl) is begin Put_Line ("ini"); raise Program_Error; end Initialize; function Elaborator return Boolean is begin Put_Line ("elb"); declare Obj : Ctrl; begin Put_Line ("ERROR: ABE not detected"); end; return True; exception when Program_Error => Put_Line ("OK"); return True; end Elaborator; Elab : constant Boolean := Elaborator; procedure Finalize (Obj : in out Ctrl) is begin Put_Line ("fin"); end Finalize; end Pack; -- main.adb with Pack; procedure Main is begin null; end Main; ---------------------------- -- Compilation and output -- ---------------------------- $ gnatmake -q main.adb $ ./main elb ini OK Tested on x86_64-pc-linux-gnu, committed on trunk 2017-11-08 Hristian Kirtchev <kirtchev@adacore.com> * sem_elab.adb (Ensure_Prior_Elaboration): Add new parameter In_Partial_Fin along with a comment on its usage. Do not guarantee the prior elaboration of a unit when the need came from a partial finalization context. (In_Initialization_Context): Relocated to Process_Call. (Is_Partial_Finalization_Proc): New routine. (Process_Access): Add new parameter In_Partial_Fin along with a comment on its usage. (Process_Activation_Call): Add new parameter In_Partial_Fin along with a comment on its usage. (Process_Activation_Conditional_ABE_Impl): Add new parameter In_Partial_Fin along with a comment on its usage. Do not emit any ABE diagnostics when the activation occurs in a partial finalization context. (Process_Activation_Guaranteed_ABE_Impl): Add new parameter In_Partial_Fin along with a comment on its usage. (Process_Call): Add new parameter In_Partial_Fin along with a comment on its usage. A call is within a partial finalization context when it targets a finalizer or primitive [Deep_]Finalize, and the call appears in initialization actions. Pass this information down to the recursive steps of the Processing phase. (Process_Call_Ada): Add new parameter In_Partial_Fin along with a comment on its usage. Remove the guard which suppresses the generation of implicit Elaborate[_All] pragmas. This is now done in Ensure_Prior_Elaboration. (Process_Call_Conditional_ABE): Add new parameter In_Partial_Fin along with a comment on its usage. Do not emit any ABE diagnostics when the call occurs in a partial finalization context. (Process_Call_SPARK): Add new parameter In_Partial_Fin along with a comment on its usage. (Process_Instantiation): Add new parameter In_Partial_Fin along with a comment on its usage. (Process_Instantiation_Ada): Add new parameter In_Partial_Fin along with a comment on its usage. (Process_Instantiation_Conditional_ABE): Add new parameter In_Partial_Fin along with a comment on its usage. Do not emit any ABE diagnostics when the instantiation occurs in a partial finalization context. (Process_Instantiation_SPARK): Add new parameter In_Partial_Fin along with a comment on its usage. (Process_Scenario): Add new parameter In_Partial_Fin along with a comment on its usage. (Process_Single_Activation): Add new parameter In_Partial_Fin along with a comment on its usage. (Traverse_Body): Add new parameter In_Partial_Fin along with a comment on its usage.
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] |