public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9177] Avoid exception propagation during bootstrap
@ 2021-10-20  8:47 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2021-10-20  8:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:40b209e340b610248f9b1eec082f6b1ff734a2d0

commit r11-9177-g40b209e340b610248f9b1eec082f6b1ff734a2d0
Author: Arnaud Charlet <charlet@adacore.com>
Date:   Wed Oct 20 10:23:40 2021 +0200

    Avoid exception propagation during bootstrap
    
    This addresses PR ada/100486, which is the bootstrap failure of GCC 11 for
    32-bit Windows in the MSYS setup.  The PR shows that we cannot rely on
    exception propagation being operational during the bootstrap, at least on
    the 11 branch, so fix this by removing the problematic raise statement.
    
    gcc/ada/
            PR ada/100486
            * sem_prag.adb (Check_Valid_Library_Unit_Pragma): Do not raise an
            exception as part of the bootstrap.

Diff:
---
 gcc/ada/sem_prag.adb | 74 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 69 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 3ef5e82c76f..e7346d5711d 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -4088,8 +4088,10 @@ package body Sem_Prag is
       --  than library level instantiations these can appear in contexts which
       --  would normally be invalid (they only apply to the original template
       --  and to library level instantiations), and they are simply ignored,
-      --  which is implemented by rewriting them as null statements and raising
-      --  exception to terminate analysis.
+      --  which is implemented by rewriting them as null statements and
+      --  optionally raising Pragma_Exit to terminate analysis. An exception
+      --  is not always raised to avoid exception propagation during the
+      --  bootstrap, so all callers should check whether N has been rewritten.
 
       procedure Check_Variant (Variant : Node_Id; UU_Typ : Entity_Id);
       --  Check an Unchecked_Union variant for lack of nested variants and
@@ -6601,8 +6603,14 @@ package body Sem_Prag is
                Sindex := Source_Index (Current_Sem_Unit);
 
                if Loc not in Source_First (Sindex) .. Source_Last (Sindex) then
+                  --  We do not want to raise an exception here since this code
+                  --  is part of the bootstrap path where we cannot rely on
+                  --  exception proapgation working.
+                  --  Instead the caller should check for N being rewritten as
+                  --  a null statement.
+                  --  This code triggers when compiling a-except.adb.
+
                   Rewrite (N, Make_Null_Statement (Loc));
-                  raise Pragma_Exit;
 
                --  If before first declaration, the pragma applies to the
                --  enclosing unit, and the name if present must be this name.
@@ -12570,6 +12578,13 @@ package body Sem_Prag is
             Check_Ada_83_Warning;
             Check_Valid_Library_Unit_Pragma;
 
+            --  If N was rewritten as a null statement there is nothing more
+            --  to do.
+
+            if Nkind (N) = N_Null_Statement then
+               return;
+            end if;
+
             Lib_Entity := Find_Lib_Unit_Name;
 
             --  A pragma that applies to a Ghost entity becomes Ghost for the
@@ -15782,6 +15797,13 @@ package body Sem_Prag is
             Check_Ada_83_Warning;
             Check_Valid_Library_Unit_Pragma;
 
+            --  If N was rewritten as a null statement there is nothing more
+            --  to do.
+
+            if Nkind (N) = N_Null_Statement then
+               return;
+            end if;
+
             Cunit_Node := Cunit (Current_Sem_Unit);
             Cunit_Ent  := Cunit_Entity (Current_Sem_Unit);
 
@@ -19486,6 +19508,13 @@ package body Sem_Prag is
             GNAT_Pragma;
             Check_Valid_Library_Unit_Pragma;
 
+            --  If N was rewritten as a null statement there is nothing more
+            --  to do.
+
+            if Nkind (N) = N_Null_Statement then
+               return;
+            end if;
+
             --  Must appear for a spec or generic spec
 
             if Nkind (Unit (Cunit (Current_Sem_Unit))) not in
@@ -21271,6 +21300,13 @@ package body Sem_Prag is
             Check_Ada_83_Warning;
             Check_Valid_Library_Unit_Pragma;
 
+            --  If N was rewritten as a null statement there is nothing more
+            --  to do.
+
+            if Nkind (N) = N_Null_Statement then
+               return;
+            end if;
+
             Ent := Find_Lib_Unit_Name;
 
             --  A pragma that applies to a Ghost entity becomes Ghost for the
@@ -21907,8 +21943,15 @@ package body Sem_Prag is
 
             if Is_Wrapper_Package (Current_Scope) then
                return;
-            else
-               Check_Valid_Library_Unit_Pragma;
+            end if;
+
+            Check_Valid_Library_Unit_Pragma;
+
+            --  If N was rewritten as a null statement there is nothing more
+            --  to do.
+
+            if Nkind (N) = N_Null_Statement then
+               return;
             end if;
 
             Ent := Find_Lib_Unit_Name;
@@ -22447,6 +22490,13 @@ package body Sem_Prag is
             Check_Ada_83_Warning;
             Check_Valid_Library_Unit_Pragma;
 
+            --  If N was rewritten as a null statement there is nothing more
+            --  to do.
+
+            if Nkind (N) = N_Null_Statement then
+               return;
+            end if;
+
             Cunit_Node := Cunit (Current_Sem_Unit);
             K          := Nkind (Unit (Cunit_Node));
             Cunit_Ent  := Cunit_Entity (Current_Sem_Unit);
@@ -22486,6 +22536,13 @@ package body Sem_Prag is
             Check_Ada_83_Warning;
             Check_Valid_Library_Unit_Pragma;
 
+            --  If N was rewritten as a null statement there is nothing more
+            --  to do.
+
+            if Nkind (N) = N_Null_Statement then
+               return;
+            end if;
+
             Cunit_Node := Cunit (Current_Sem_Unit);
             Cunit_Ent  := Cunit_Entity (Current_Sem_Unit);
 
@@ -22682,6 +22739,13 @@ package body Sem_Prag is
             Check_Ada_83_Warning;
             Check_Valid_Library_Unit_Pragma;
 
+            --  If N was rewritten as a null statement there is nothing more
+            --  to do.
+
+            if Nkind (N) = N_Null_Statement then
+               return;
+            end if;
+
             Cunit_Node := Cunit (Current_Sem_Unit);
             Cunit_Ent  := Cunit_Entity (Current_Sem_Unit);


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

only message in thread, other threads:[~2021-10-20  8:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20  8:47 [gcc r11-9177] Avoid exception propagation during bootstrap 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).