public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5657] ada: Avoid Style_Checks pragmas affecting other units
@ 2023-11-21  9:59 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-11-21  9:59 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3827a017667532656285c9cf7f6448ff688221a9

commit r14-5657-g3827a017667532656285c9cf7f6448ff688221a9
Author: Viljar Indus <indus@adacore.com>
Date:   Thu Oct 12 14:09:27 2023 +0300

    ada: Avoid Style_Checks pragmas affecting other units
    
    gcc/ada/
    
            * par.adb: Restore Style_Checks after parsing each unit.

Diff:
---
 gcc/ada/par.adb | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb
index 180ec08561c..4e10dd9049c 100644
--- a/gcc/ada/par.adb
+++ b/gcc/ada/par.adb
@@ -80,6 +80,10 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
    --  True within a delta aggregate (but only after the "delta" token has
    --  been scanned). Used to distinguish syntax errors from syntactically
    --  correct "deep" delta aggregates (enabled via -gnatX0).
+   Save_Style_Checks : Style_Check_Options;
+   Save_Style_Check  : Boolean;
+   --  Variables for storing the original state of whether style checks should
+   --  be active in general and which particular ones should be checked.
 
    --------------------
    -- Error Recovery --
@@ -1601,6 +1605,11 @@ begin
    else
       Save_Config_Attrs := Save_Config_Switches;
 
+      --  Store the state of Style_Checks pragamas
+
+      Save_Style_Check := Style_Check;
+      Save_Style_Check_Options (Save_Style_Checks);
+
       --  The following loop runs more than once in syntax check mode
       --  where we allow multiple compilation units in the same file
       --  and in Multiple_Unit_Per_file mode where we skip units till
@@ -1658,6 +1667,7 @@ begin
          --  syntax mode we are interested in all units in the file.
 
          else
+
             declare
                Comp_Unit_Node : constant Node_Id := P_Compilation_Unit;
 
@@ -1744,6 +1754,13 @@ begin
          Restore_Config_Switches (Save_Config_Attrs);
       end loop;
 
+      --  Restore the state of Style_Checks after parsing the unit to
+      --  avoid parsed pragmas affecting other units.
+
+      Reset_Style_Check_Options;
+      Set_Style_Check_Options (Save_Style_Checks);
+      Style_Check := Save_Style_Check;
+
       --  Now that we have completely parsed the source file, we can complete
       --  the source file table entry.

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

only message in thread, other threads:[~2023-11-21  9:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21  9:59 [gcc r14-5657] ada: Avoid Style_Checks pragmas affecting other units Marc Poulhi?s

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).