public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Fix scope of semantic style_check pragmas
@ 2023-11-07  9:19 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-11-07  9:19 UTC (permalink / raw)
  To: gcc-patches; +Cc: Viljar Indus

From: Viljar Indus <indus@adacore.com>

Restore the original state of Style_Check pragmas before analyzing
each compilation unit to avoid Style_Check pragmas from unit affecting
the style checks of a different unit.

gcc/ada/

	* sem_ch10.adb: (Analyze_Compilation_Unit): Restore the orignal
	state of style check pragmas at the end of the analysis.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch10.adb | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb
index ba4beae2851..90d2f3c6c74 100644
--- a/gcc/ada/sem_ch10.adb
+++ b/gcc/ada/sem_ch10.adb
@@ -638,6 +638,7 @@ package body Sem_Ch10 is
       Par_Spec_Name : Unit_Name_Type;
       Spec_Id       : Entity_Id;
       Unum          : Unit_Number_Type;
+      Options       : Style_Check_Options;
 
    --  Start of processing for Analyze_Compilation_Unit
 
@@ -717,6 +718,11 @@ package body Sem_Ch10 is
          Set_Context_Pending (N);
       end if;
 
+      --  Store the style check options before analyzing context pragmas that
+      --  might change them for this compilation unit.
+
+      Save_Style_Check_Options (Options);
+
       Analyze_Context (N);
 
       Set_Context_Pending (N, False);
@@ -1395,6 +1401,10 @@ package body Sem_Ch10 is
          Pop_Scope;
       end if;
 
+      --  Finally restore all the original style check options
+
+      Set_Style_Check_Options (Options);
+
       --  If No_Elaboration_Code_All was encountered, this is where we do the
       --  transitive test of with'ed units to make sure they have the aspect.
       --  This is delayed till the end of analyzing the compilation unit to
-- 
2.42.0


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-07  9:19 [COMMITTED] ada: Fix scope of semantic style_check pragmas 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).