https://gcc.gnu.org/g:37c33c6a1c86ba88db8f0cf2e398374f0e501038
commit r17-4609-g37c33c6a1c86ba88db8f0cf2e398374f0e501038 Author: Eric Botcazou <[email protected]> Date: Wed Sep 23 11:39:49 2026 +0200 Ada: Small tweak to Establish_Transient_Scope.Find_Transient_Context It pertains to the distinction between simple and compound statements for the determination of master constructs, which then act as a boundary for a transient scope. gcc/ada/ * exp_ch7.adb (Establish_Transient_Scope.Find_Transient_Context): Add commentary about the distinction between compound and simple statements, and adjust handling for code and delay statements. Diff: --- gcc/ada/exp_ch7.adb | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 338a5de8057c..c46cd8cd2ef1 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -4385,23 +4385,19 @@ package body Exp_Ch7 is => return Curr; - -- Statements + -- Statements and statement-like constructs - -- Statements and statement-like constructs act as a boundary - -- for a transient scope. + -- Expressions of compound statements are master constructs so + -- they act as a boundary for a transient scope. when N_Accept_Alternative | N_Attribute_Definition_Clause | N_Case_Statement | N_Case_Statement_Alternative - | N_Code_Statement | N_Delay_Alternative - | N_Delay_Until_Statement - | N_Delay_Relative_Statement | N_Discriminant_Association | N_Elsif_Part | N_Entry_Body_Formal_Part - | N_Exit_Statement | N_If_Statement | N_Iteration_Scheme | N_Terminate_Alternative @@ -4409,7 +4405,23 @@ package body Exp_Ch7 is pragma Assert (Present (Prev)); return Prev; - when N_Assignment_Statement => + -- An exit statement only alters the control flow, so there + -- is no need to wait until after its completion to finalize + -- its expression (which is however not a master construct). + + when N_Exit_Statement => + pragma Assert (Present (Prev)); + return Prev; + + -- Expressions of simple statements are not master constructs + -- (except for a simple return), so only the statements act as + -- a boundary for a transient scope. + + when N_Assignment_Statement + | N_Code_Statement + | N_Delay_Relative_Statement + | N_Delay_Until_Statement + => return Curr; when N_Entry_Call_Statement
