From 27b95a65410ccb700752c8178fd19f1485a4b5bf Mon Sep 17 00:00:00 2001 From: Olivier Hainque Date: Tue, 19 Apr 2016 13:19:45 +0000 Subject: [PATCH] sem_util.adb (Build_Elaboration_Entity): Always request an elab counter when preserving control-flow. 2016-04-19 Olivier Hainque * sem_util.adb (Build_Elaboration_Entity): Always request an elab counter when preserving control-flow. 2016-04-19 Olivier Hainque * sem_ch13.adb (Build_Invariant_Procedure_Declaration): Set Needs_Debug_Info when producing SCOs. * par_sco.adb (Traverse_Aspects): Fix categorization of Type_Invariant to match actual processing as activated depending on pragma Assertion_Policy. * sem_prag.adb (Analyze_Pragma): Remove special case for Name_Invariant regarding SCO generation, which completely disabled the production of SCOs for Invariant pragmas and aspects. From-SVN: r235202 --- gcc/ada/ChangeLog | 16 ++++++++++++++++ gcc/ada/par_sco.adb | 31 ++++++++++++++++++++----------- gcc/ada/sem_ch13.adb | 8 ++++++++ gcc/ada/sem_prag.adb | 8 ++++---- gcc/ada/sem_util.adb | 14 +++++++++++--- 5 files changed, 59 insertions(+), 18 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 3a514cd1d42..3737bf36eb3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,19 @@ +2016-04-19 Olivier Hainque + + * sem_util.adb (Build_Elaboration_Entity): Always request an + elab counter when preserving control-flow. + +2016-04-19 Olivier Hainque + + * sem_ch13.adb (Build_Invariant_Procedure_Declaration): Set + Needs_Debug_Info when producing SCOs. + * par_sco.adb (Traverse_Aspects): Fix categorization of + Type_Invariant to match actual processing as activated depending + on pragma Assertion_Policy. + * sem_prag.adb (Analyze_Pragma): Remove special case for + Name_Invariant regarding SCO generation, which completely disabled + the production of SCOs for Invariant pragmas and aspects. + 2016-04-19 Hristian Kirtchev * checks.adb, sem_util.adb, sem_res.adb, sem_attr.adb: Minor diff --git a/gcc/ada/par_sco.adb b/gcc/ada/par_sco.adb index c1e6f037781..e55742df4ad 100644 --- a/gcc/ada/par_sco.adb +++ b/gcc/ada/par_sco.adb @@ -1640,11 +1640,12 @@ package body Par_SCO is -- specification. The corresponding pragma will have the same -- sloc. - when Aspect_Pre | - Aspect_Precondition | - Aspect_Post | - Aspect_Postcondition | - Aspect_Invariant => + when Aspect_Pre | + Aspect_Precondition | + Aspect_Post | + Aspect_Postcondition | + Aspect_Type_Invariant | + Aspect_Invariant => C1 := 'a'; @@ -1660,8 +1661,7 @@ package body Par_SCO is when Aspect_Predicate | Aspect_Static_Predicate | - Aspect_Dynamic_Predicate | - Aspect_Type_Invariant => + Aspect_Dynamic_Predicate => C1 := 'A'; @@ -2397,8 +2397,8 @@ package body Par_SCO is Sync_Def : Node_Id; -- N's protected or task definition - Vis_Decl : List_Id; - -- Sync_Def's Visible_Declarations + Vis_Decl, Priv_Decl : List_Id; + -- Sync_Def's Visible_Declarations and Private_Declarations begin case Nkind (N) is @@ -2412,7 +2412,16 @@ package body Par_SCO is raise Program_Error; end case; - Vis_Decl := Visible_Declarations (Sync_Def); + -- Sync_Def may be Empty at least for empty Task_Type_Declarations. + -- Querying Visible or Private_Declarations is invalid in this case. + + if Present (Sync_Def) then + Vis_Decl := Visible_Declarations (Sync_Def); + Priv_Decl := Private_Declarations (Sync_Def); + else + Vis_Decl := No_List; + Priv_Decl := No_List; + end if; Dom_Info := Traverse_Declarations_Or_Statements (L => Vis_Decl, @@ -2422,7 +2431,7 @@ package body Par_SCO is -- is dominated by the last visible declaration. Traverse_Declarations_Or_Statements - (L => Private_Declarations (Sync_Def), + (L => Priv_Decl, D => Dom_Info); end Traverse_Sync_Definition; diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 2d6d922f318..b436b43a086 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -7841,6 +7841,14 @@ package body Sem_Ch13 is Set_Is_Invariant_Procedure (SId); Set_Invariant_Procedure (Typ, SId); + -- Source Coverage Obligations might be attached to the invariant + -- expression this procedure evaluates, and we need debug info to be + -- able to assess the coverage achieved by evaluations. + + if Opt.Generate_SCO then + Set_Needs_Debug_Info (SId); + end if; + -- Mark the invariant procedure explicitly as Ghost because it does not -- come from source. diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 289cfc8274a..d929c852c94 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -12265,11 +12265,11 @@ package body Sem_Prag is case Cname is - -- Nothing to do for invariants and predicates as the checks - -- occur in the client units. The SCO for the aspect in the - -- declaration unit is conservatively always enabled. + -- Nothing to do for predicates as the checks occur in the + -- client units. The SCO for the aspect in the declaration + -- unit is conservatively always enabled. - when Name_Invariant | Name_Predicate => + when Name_Predicate => null; -- Otherwise mark aspect/pragma SCO as enabled diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 0d9b4d14394..ba4f0321c2d 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -1662,9 +1662,17 @@ package body Sem_Util is elsif ASIS_Mode then return; - -- See if we need elaboration entity. We always need it for the dynamic - -- elaboration model, since it is needed to properly generate the PE - -- exception for access before elaboration. + -- See if we need elaboration entity. + + -- We always need an elaboration entity when preserving control-flow, as + -- we want to remain explicit about the units elaboration order. + + elsif Opt.Suppress_Control_Flow_Optimizations then + null; + + -- We always need an elaboration entity for the dynamic elaboration + -- model, since it is needed to properly generate the PE exception for + -- access before elaboration. elsif Dynamic_Elaboration_Checks then null; -- 2.30.2