public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-349] [Ada] Fix scope of block in expanded protected entry body
Date: Thu, 12 May 2022 12:40:16 +0000 (GMT)	[thread overview]
Message-ID: <20220512124016.CADF9383D819@sourceware.org> (raw)

https://gcc.gnu.org/g:bb1c939d9b800ef9aadf8a82cbafdfae5c88210c

commit r13-349-gbb1c939d9b800ef9aadf8a82cbafdfae5c88210c
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Fri Feb 4 20:56:51 2022 +0100

    [Ada] Fix scope of block in expanded protected entry body
    
    We expand protected entry body into procedure with a nested block. The
    scope of this block is naturally the enclosing procedure. However, the
    scope field was wrongly set to the entity of the enclosing procedure
    body (i.e. E_Subprogram_Body); now it is set to the entity of the
    enclosing procedure spec (i.e. E_Procedure).
    
    In general, the scope field should always points to spec, even for
    entities that are syntactically nested within a program unit body. The
    scope set to E_Subprogram_Body entity was only accepted because in gigi
    we had a protection for that, but this protection is now removed.
    
    This patch fixes a regression in a ravenscar testsuite test (c_rf02_06),
    where GNAT was crashing when compiling in configurable runtime mode with
    restriction No_Exception_Propagation.
    
    gcc/ada/
    
            * exp_ch9.adb (Build_Protected_Entry): Set scope of the nested
            block to spec and not the body of the procedure created for a
            protected entry.

Diff:
---
 gcc/ada/exp_ch9.adb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index 04a87fb4f9a..f7067805979 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -3707,7 +3707,8 @@ package body Exp_Ch9 is
 
       Analyze_Statements (Bod_Stmts);
 
-      Set_Scope (Entity (Identifier (First (Bod_Stmts))), Bod_Id);
+      Set_Scope (Entity (Identifier (First (Bod_Stmts))),
+                 Protected_Body_Subprogram (Ent));
 
       Reset_Scopes_To
         (First (Bod_Stmts), Entity (Identifier (First (Bod_Stmts))));


                 reply	other threads:[~2022-05-12 12:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220512124016.CADF9383D819@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).