public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-7874] ada: Fix wrong finalization for case expression in expression function
@ 2023-09-27  8:25 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2023-09-27  8:25 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:15467940a5b17193a4650567d856c7b30b7f1f34

commit r13-7874-g15467940a5b17193a4650567d856c7b30b7f1f34
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri Apr 7 00:26:19 2023 +0200

    ada: Fix wrong finalization for case expression in expression function
    
    This happens when the case expression contains a single alternative.
    
    gcc/ada/
    
            * exp_ch5.adb (Expand_N_Case_Statement): Do not remove the statement
            if it is the node to be wrapped by a transient scope.

Diff:
---
 gcc/ada/exp_ch5.adb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index d605f75d147..4eb9adefc96 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -4079,11 +4079,15 @@ package body Exp_Ch5 is
 
          --  If there is only a single alternative, just replace it with the
          --  sequence of statements since obviously that is what is going to
-         --  be executed in all cases.
+         --  be executed in all cases, except if it is the node to be wrapped
+         --  by a transient scope, because this would cause the sequence of
+         --  statements to be leaked out of the transient scope.
 
          Len := List_Length (Alternatives (N));
 
-         if Len = 1 then
+         if Len = 1
+           and then not (Scope_Is_Transient and then Node_To_Be_Wrapped = N)
+         then
 
             --  We still need to evaluate the expression if it has any side
             --  effects.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-27  8:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27  8:25 [gcc r13-7874] ada: Fix wrong finalization for case expression in expression function Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).