public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1612] [Ada] Replace Opt.Extensions_Allowed by Ada_Version
@ 2021-06-18  8:37 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-18  8:37 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5ddd01d6d41846eeb4b5e55351a4910841504510

commit r12-1612-g5ddd01d6d41846eeb4b5e55351a4910841504510
Author: Arnaud Charlet <charlet@adacore.com>
Date:   Sun Mar 14 15:49:39 2021 -0400

    [Ada] Replace Opt.Extensions_Allowed by Ada_Version
    
    gcc/ada/
    
            * fe.h, opt.adb, opt.ads, par-prag.adb, sem_prag.adb,
            switch-c.adb (Extensions_Allowed): Replace by a function.
            (Ada_Version_Type): Add new value Ada_With_Extensions, to
            replace setting of Extensions_Allowed.  Update setting of
            Extensions_Allowed.

Diff:
---
 gcc/ada/fe.h         |  2 +-
 gcc/ada/opt.adb      |  5 -----
 gcc/ada/opt.ads      | 28 +++++++++++-----------------
 gcc/ada/par-prag.adb |  4 +---
 gcc/ada/sem_prag.adb |  5 +----
 gcc/ada/switch-c.adb |  5 ++---
 6 files changed, 16 insertions(+), 33 deletions(-)

diff --git a/gcc/ada/fe.h b/gcc/ada/fe.h
index 631773738cf..dc2b4165c34 100644
--- a/gcc/ada/fe.h
+++ b/gcc/ada/fe.h
@@ -203,7 +203,7 @@ extern Boolean In_Extended_Main_Code_Unit	(Entity_Id);
 #define Suppress_Checks			opt__suppress_checks
 
 typedef enum {
-  Ada_83, Ada_95, Ada_2005, Ada_2012, Ada_2022
+  Ada_83, Ada_95, Ada_2005, Ada_2012, Ada_2022, Ada_With_Extensions
 } Ada_Version_Type;
 
 typedef enum {
diff --git a/gcc/ada/opt.adb b/gcc/ada/opt.adb
index a2d6eda016a..cd909495beb 100644
--- a/gcc/ada/opt.adb
+++ b/gcc/ada/opt.adb
@@ -84,7 +84,6 @@ package body Opt is
       Default_SSO_Config                    := Default_SSO;
       Dynamic_Elaboration_Checks_Config     := Dynamic_Elaboration_Checks;
       Exception_Locations_Suppressed_Config := Exception_Locations_Suppressed;
-      Extensions_Allowed_Config             := Extensions_Allowed;
       External_Name_Exp_Casing_Config       := External_Name_Exp_Casing;
       External_Name_Imp_Casing_Config       := External_Name_Imp_Casing;
       Fast_Math_Config                      := Fast_Math;
@@ -123,7 +122,6 @@ package body Opt is
       Default_SSO                    := Save.Default_SSO;
       Dynamic_Elaboration_Checks     := Save.Dynamic_Elaboration_Checks;
       Exception_Locations_Suppressed := Save.Exception_Locations_Suppressed;
-      Extensions_Allowed             := Save.Extensions_Allowed;
       External_Name_Exp_Casing       := Save.External_Name_Exp_Casing;
       External_Name_Imp_Casing       := Save.External_Name_Imp_Casing;
       Fast_Math                      := Save.Fast_Math;
@@ -165,7 +163,6 @@ package body Opt is
          Default_SSO                    => Default_SSO,
          Dynamic_Elaboration_Checks     => Dynamic_Elaboration_Checks,
          Exception_Locations_Suppressed => Exception_Locations_Suppressed,
-         Extensions_Allowed             => Extensions_Allowed,
          External_Name_Exp_Casing       => External_Name_Exp_Casing,
          External_Name_Imp_Casing       => External_Name_Imp_Casing,
          Fast_Math                      => Fast_Math,
@@ -204,7 +201,6 @@ package body Opt is
          Ada_Version_Pragma          := Empty;
          Default_SSO                 := ' ';
          Dynamic_Elaboration_Checks  := False;
-         Extensions_Allowed          := True;
          External_Name_Exp_Casing    := As_Is;
          External_Name_Imp_Casing    := Lowercase;
          No_Component_Reordering     := False;
@@ -263,7 +259,6 @@ package body Opt is
          Check_Policy_List           := Check_Policy_List_Config;
          Default_SSO                 := Default_SSO_Config;
          Dynamic_Elaboration_Checks  := Dynamic_Elaboration_Checks_Config;
-         Extensions_Allowed          := Extensions_Allowed_Config;
          External_Name_Exp_Casing    := External_Name_Exp_Casing_Config;
          External_Name_Imp_Casing    := External_Name_Imp_Casing_Config;
          Fast_Math                   := Fast_Math_Config;
diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads
index 429bd423474..5384bd9da3f 100644
--- a/gcc/ada/opt.ads
+++ b/gcc/ada/opt.ads
@@ -68,17 +68,20 @@ package Opt is
    --  the default values.
 
    Latest_Ada_Only : Boolean := False;
-   --  If True, the only value valid for Ada_Version is Ada_Version_Type'Last,
-   --  trying to specify other values will be ignored (in case of pragma
+   --  If True, the only value valid for Ada_Version is Ada_2012 or later.
+   --  Trying to specify other values will be ignored (in case of pragma
    --  Ada_xxx) or generate an error (in case of -gnat83/95/xx switches).
 
-   type Ada_Version_Type is (Ada_83, Ada_95, Ada_2005, Ada_2012, Ada_2022);
+   type Ada_Version_Type is
+     (Ada_83, Ada_95, Ada_2005, Ada_2012, Ada_2022, Ada_With_Extensions);
    pragma Ordered (Ada_Version_Type);
    pragma Convention (C, Ada_Version_Type);
    --  Versions of Ada for Ada_Version below. Note that these are ordered,
    --  so that tests like Ada_Version >= Ada_95 are legitimate and useful.
    --  Think twice before using "="; Ada_Version >= Ada_2012 is more likely
    --  what you want, because it will apply to future versions of the language.
+   --  Note that Ada_With_Extensions should always be last since it should
+   --  always be a superset of the latest Ada version.
 
    --  WARNING: There is a matching C declaration of this type in fe.h
 
@@ -108,7 +111,7 @@ package Opt is
    --  remains set to Ada_Version_Default). This is used in the rare cases
    --  (notably pragma Obsolescent) where we want the explicit version set.
 
-   Ada_Version_Runtime : Ada_Version_Type := Ada_2022;
+   Ada_Version_Runtime : Ada_Version_Type := Ada_With_Extensions;
    --  GNAT
    --  Ada version used to compile the runtime. Used to set Ada_Version (but
    --  not Ada_Version_Explicit) when compiling predefined or internal units.
@@ -623,10 +626,10 @@ package Opt is
    --  Set to True to convert nonbinary modular additions into code
    --  that relies on the front-end expansion of operator Mod.
 
-   Extensions_Allowed : Boolean := False;
-   --  GNAT
-   --  Set to True by switch -gnatX if GNAT specific language extensions
-   --  are allowed. See GNAT RM for details.
+   function Extensions_Allowed return Boolean is
+     (Ada_Version = Ada_With_Extensions);
+   --  True if GNAT specific language extensions are allowed. See GNAT RM for
+   --  details.
 
    type External_Casing_Type is (
      As_Is,       -- External names cased as they appear in the Ada source
@@ -2040,14 +2043,6 @@ package Opt is
    --  GNAT
    --  Set True by use of the configuration pragma Suppress_Exception_Messages
 
-   Extensions_Allowed_Config : Boolean;
-   --  GNAT
-   --  This is the flag that indicates whether extensions are allowed. It can
-   --  be set True either by use of the -gnatX switch, or by use of the
-   --  configuration pragma Extensions_Allowed (On). It is always set to True
-   --  for internal GNAT units, since extensions are always permitted in such
-   --  units.
-
    External_Name_Exp_Casing_Config : External_Casing_Type;
    --  GNAT
    --  This is the value of the configuration switch that controls casing of
@@ -2331,7 +2326,6 @@ private
       Default_SSO                    : Character;
       Dynamic_Elaboration_Checks     : Boolean;
       Exception_Locations_Suppressed : Boolean;
-      Extensions_Allowed             : Boolean;
       External_Name_Exp_Casing       : External_Casing_Type;
       External_Name_Imp_Casing       : External_Casing_Type;
       Fast_Math                      : Boolean;
diff --git a/gcc/ada/par-prag.adb b/gcc/ada/par-prag.adb
index 33182ccd6ce..4c5efc6ab11 100644
--- a/gcc/ada/par-prag.adb
+++ b/gcc/ada/par-prag.adb
@@ -443,10 +443,8 @@ begin
          Check_Arg_Is_On_Or_Off (Arg1);
 
          if Chars (Expression (Arg1)) = Name_On then
-            Extensions_Allowed := True;
-            Ada_Version := Ada_Version_Type'Last;
+            Ada_Version := Ada_With_Extensions;
          else
-            Extensions_Allowed := False;
             Ada_Version := Ada_Version_Explicit;
          end if;
 
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index a65864dfa83..3e6af337dcd 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -16456,11 +16456,8 @@ package body Sem_Prag is
             Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
 
             if Chars (Get_Pragma_Arg (Arg1)) = Name_On then
-               Extensions_Allowed := True;
-               Ada_Version := Ada_Version_Type'Last;
-
+               Ada_Version := Ada_With_Extensions;
             else
-               Extensions_Allowed := False;
                Ada_Version := Ada_Version_Explicit;
                Ada_Version_Pragma := Empty;
             end if;
diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb
index af9e679c808..020be635401 100644
--- a/gcc/ada/switch-c.adb
+++ b/gcc/ada/switch-c.adb
@@ -1392,9 +1392,8 @@ package body Switch.C is
 
             when 'X' =>
                Ptr := Ptr + 1;
-               Extensions_Allowed   := True;
-               Ada_Version          := Ada_Version_Type'Last;
-               Ada_Version_Explicit := Ada_Version_Type'Last;
+               Ada_Version          := Ada_With_Extensions;
+               Ada_Version_Explicit := Ada_With_Extensions;
                Ada_Version_Pragma   := Empty;
 
             --  -gnaty (style checks)


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

only message in thread, other threads:[~2021-06-18  8:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  8:37 [gcc r12-1612] [Ada] Replace Opt.Extensions_Allowed by Ada_Version Pierre-Marie de Rodat

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