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 r12-5680] [Ada] Fix crash on pragma Compile_Time_Warning/Error
Date: Wed,  1 Dec 2021 10:27:21 +0000 (GMT)	[thread overview]
Message-ID: <20211201102721.88B48385842A@sourceware.org> (raw)

https://gcc.gnu.org/g:9ce9322ccc4aa873d732554c895b821c90017511

commit r12-5680-g9ce9322ccc4aa873d732554c895b821c90017511
Author: Bob Duff <duff@adacore.com>
Date:   Wed Nov 17 12:06:32 2021 -0500

    [Ada] Fix crash on pragma Compile_Time_Warning/Error
    
    gcc/ada/
    
            * sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Do not
            follow the Corresponding_Spec pointer if Acts_As_Spec is True,
            because Corresponding_Spec is Empty in that case, so we would
            exit the loop prematurely, and incorrectly think we are not
            inside a generic unit when we are.

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

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 1d5cc2535bd..9fdec53b374 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -7827,11 +7827,15 @@ package body Sem_Prag is
 
          if Compile_Time_Known_Value (Arg1x) then
             Validate_Compile_Time_Warning_Or_Error (N, Sloc (Arg1));
+
          else
             while Present (P) and then Nkind (P) not in N_Generic_Declaration
             loop
-               if Nkind (P) in N_Package_Body | N_Subprogram_Body then
-                  P := Corresponding_Spec (P);
+               if (Nkind (P) = N_Subprogram_Body and then not Acts_As_Spec (P))
+                 or else Nkind (P) = N_Package_Body
+               then
+                  P := Parent (Corresponding_Spec (P));
+
                else
                   P := Parent (P);
                end if;


                 reply	other threads:[~2021-12-01 10:27 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=20211201102721.88B48385842A@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).