From: Bob Duff <d...@adacore.com>

Remove all user-level documentation of the check name
"Atomic_Synchronization". The documentation was confusing because
this check should never be used in source code, and because it
raises the question of whether All_Checks applies to it (it does
not).

Change the name Atomic_Synchronization to be _Atomic_Synchronization
(with a leading underscore) so that it cannot be used in source code.

This "check" is not really a check at all; it is used only internally in
the implementation of Disable/Enable_Atomic_Synchronization, because the
placement and scope of these pragmas match pragma Suppress.

gcc/ada/ChangeLog:

        * doc/gnat_rm/implementation_defined_characteristics.rst:
        Remove Atomic_Synchronization.
        * doc/gnat_ugn/building_executable_programs_with_gnat.rst:
        Likewise.
        * doc/gnat_rm/implementation_defined_pragmas.rst: DRY.
        Consolidate documentation of Disable/Enable_Atomic_Synchronization.
        * checks.adb: Comment fix.
        * exp_util.ads: Likewise.
        * targparm.ads: Likewise.
        * types.ads: Likewise.
        * gnat1drv.adb: Likewise. DRY.
        * sem_prag.adb (Process_Disable_Enable_Atomic_Sync):
        Change name of Atomic_Synchronization to start with
        underscore.
        (Process_Suppress_Unsuppress): No need to check Comes_From_Source for
        Atomic_Synchronization anymore; _Atomic_Synchronization can never
        come from source. (Anyway, it shouldn't be ignored; it should be
        an error.)
        * snames.ads-tmpl (Atomic_Synchronization):
        Change name to start with underscore.
        * switch-c.adb (Scan_Front_End_Switches):
        Minor cleanup: Use 'in'.
        * gnat_rm.texi: Regenerate.
        * gnat_ugn.texi: Regenerate.

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

---
 gcc/ada/checks.adb                            |  6 ++-
 ...implementation_defined_characteristics.rst | 12 ++---
 .../implementation_defined_pragmas.rst        | 35 +++++--------
 ...building_executable_programs_with_gnat.rst |  6 +--
 gcc/ada/exp_util.ads                          |  6 +--
 gcc/ada/gnat1drv.adb                          |  5 +-
 gcc/ada/gnat_rm.texi                          | 49 ++++++++-----------
 gcc/ada/gnat_ugn.texi                         | 10 ++--
 gcc/ada/sem_prag.adb                          | 19 +++----
 gcc/ada/snames.ads-tmpl                       |  6 +--
 gcc/ada/switch-c.adb                          |  4 +-
 gcc/ada/targparm.ads                          |  6 +--
 gcc/ada/types.ads                             |  3 +-
 13 files changed, 66 insertions(+), 101 deletions(-)

diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 06e7997cb3f..8a3c4e8b4bf 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -3976,8 +3976,10 @@ package body Checks is
    -------------------------------------
 
    --  Note: internally Disable/Enable_Atomic_Synchronization is implemented
-   --  using a bogus check called Atomic_Synchronization. This is to make it
-   --  more convenient to get exactly the same semantics as [Un]Suppress.
+   --  using a pseudo-check called _Atomic_Synchronization. This is to make it
+   --  more convenient to get the same placement and scope rules as
+   --  [Un]Suppress. The check name has a leading underscore to make
+   --  it reserved by the implementation.
 
    function Atomic_Synchronization_Disabled (E : Entity_Id) return Boolean is
    begin
diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_characteristics.rst 
b/gcc/ada/doc/gnat_rm/implementation_defined_characteristics.rst
index 5399bda55e8..3e41899f95e 100644
--- a/gcc/ada/doc/gnat_rm/implementation_defined_characteristics.rst
+++ b/gcc/ada/doc/gnat_rm/implementation_defined_characteristics.rst
@@ -478,12 +478,12 @@ via compiler switches such as "-gnata".
 *
   "Implementation-defined check names.  See 11.5(27)."
 
-The implementation defined check names include Alignment_Check,
-Atomic_Synchronization, Container_Checks, Duplicated_Tag_Check,
-Predicate_Check, Raise_Check, Tampering_Check, and Validity_Check.
-In addition, a user program can add implementation-defined check
-names by means of the pragma Check_Name. See the description of
-pragma ``Suppress`` for full details.
+The implementation-defined check names include Alignment_Check,
+Container_Checks, Duplicated_Tag_Check, Predicate_Check,
+Raise_Check, Tampering_Check, and Validity_Check. In addition, a
+user program can add implementation-defined check names by means
+of the pragma Check_Name. See the description of pragma
+``Suppress`` for details.
 
 *
   "Existence and meaning of second parameter of pragma Unsuppress.
diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst 
b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
index 7ff94c4c2b9..61ed40e78f4 100644
--- a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
+++ b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
@@ -1662,18 +1662,20 @@ Syntax:
 
   pragma Disable_Atomic_Synchronization [(Entity)];
 
+  pragma Enable_Atomic_Synchronization [(Entity)];
 
 Ada requires that accesses (reads or writes) of an atomic variable be
 regarded as synchronization points in the case of multiple tasks.
 Particularly in the case of multi-processors this may require special
-handling, e.g. the generation of memory barriers. This capability may
-be turned off using this pragma in cases where it is known not to be
-required.
-
-The placement and scope rules for this pragma are the same as those
-for ``pragma Suppress``. In particular it can be used as a
-configuration  pragma, or in a declaration sequence where it applies
-till the end of the scope. If an ``Entity`` argument is present,
+handling, e.g. the generation of memory barriers. This synchronization
+is performed by default, but can be turned off using pragma
+``Disable_Atomic_Synchronization``.
+The ``Enable_Atomic_Synchronization`` pragma turns it back on.
+
+The placement and scope rules for these pragmas are the same as those
+for ``pragma Suppress``. In particular they can be used as
+configuration pragmas, or in a declaration sequence where they apply
+until the end of the scope. If an ``Entity`` argument is present,
 the action applies only to that entity.
 
 Pragma Dispatching_Domain
@@ -1903,21 +1905,8 @@ Syntax:
 
   pragma Enable_Atomic_Synchronization [(Entity)];
 
-
-Ada requires that accesses (reads or writes) of an atomic variable be
-regarded as synchronization points in the case of multiple tasks.
-Particularly in the case of multi-processors this may require special
-handling, e.g. the generation of memory barriers. This synchronization
-is performed by default, but can be turned off using
-``pragma Disable_Atomic_Synchronization``. The
-``Enable_Atomic_Synchronization`` pragma can be used to turn
-it back on.
-
-The placement and scope rules for this pragma are the same as those
-for ``pragma Unsuppress``. In particular it can be used as a
-configuration  pragma, or in a declaration sequence where it applies
-till the end of the scope. If an ``Entity`` argument is present,
-the action applies only to that entity.
+Reenables atomic synchronization; see ``pragma Disable_Atomic_Synchronization``
+for details.
 
 Pragma Exceptional_Cases
 ========================
diff --git a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst 
b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
index 51a9201bc5b..7870d8d7c57 100644
--- a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
+++ b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
@@ -5379,10 +5379,8 @@ switches refine this default behavior.
   execution if that assumption is wrong.
 
   The checks subject to suppression include all the checks defined by the Ada
-  standard, the additional implementation defined checks ``Alignment_Check``,
-  ``Duplicated_Tag_Check``, ``Predicate_Check``, ``Container_Checks``, 
``Tampering_Check``,
-  and ``Validity_Check``, as well as any checks introduced using ``pragma 
Check_Name``.
-  Note that ``Atomic_Synchronization`` is not automatically suppressed by use 
of this option.
+  standard, as well as all implementation-defined checks,
+  including any checks introduced using ``pragma Check_Name``.
 
   If the code depends on certain checks being active, you can use
   pragma ``Unsuppress`` either as a configuration pragma or as
diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads
index 898d712f049..0872db21491 100644
--- a/gcc/ada/exp_util.ads
+++ b/gcc/ada/exp_util.ads
@@ -182,9 +182,9 @@ package Exp_Util is
    --  N is a node for which atomic synchronization may be required (it is
    --  either an identifier, expanded name, or selected/indexed component or
    --  an explicit dereference). The caller has checked the basic conditions
-   --  (atomic variable appearing and Atomic_Sync not disabled). This function
-   --  checks if atomic synchronization is required and if so sets the flag
-   --  and if appropriate generates a warning (in -gnatw.n mode).
+   --  (atomic variable appearing and Atomic_Synchronization enabled). This
+   --  function checks if atomic synchronization is required and if so sets
+   --  the flag and (in -gnatw.n mode) generates a warning.
 
    procedure Adjust_Condition (N : Node_Id);
    --  The node N is an expression whose root-type is Boolean, and which
diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb
index acc64912280..120de4afb71 100644
--- a/gcc/ada/gnat1drv.adb
+++ b/gcc/ada/gnat1drv.adb
@@ -654,10 +654,7 @@ procedure Gnat1drv is
          end if;
       end if;
 
-      --  Set default for atomic synchronization. As this synchronization
-      --  between atomic accesses can be expensive, and not typically needed
-      --  on some targets, an optional target parameter can turn the option
-      --  off. Note Atomic Synchronization is implemented as check.
+      --  Set default for atomic synchronization
 
       Suppress_Options.Suppress (Atomic_Synchronization) :=
         not Atomic_Sync_Default_On_Target;
diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi
index 5c3f439caad..849404c8e87 100644
--- a/gcc/ada/gnat_rm.texi
+++ b/gcc/ada/gnat_rm.texi
@@ -19,7 +19,7 @@
 
 @copying
 @quotation
-GNAT Reference Manual , Nov 08, 2024
+GNAT Reference Manual , Nov 18, 2024
 
 AdaCore
 
@@ -3142,19 +3142,22 @@ Syntax:
 
 @example
 pragma Disable_Atomic_Synchronization [(Entity)];
+
+pragma Enable_Atomic_Synchronization [(Entity)];
 @end example
 
 Ada requires that accesses (reads or writes) of an atomic variable be
 regarded as synchronization points in the case of multiple tasks.
 Particularly in the case of multi-processors this may require special
-handling, e.g. the generation of memory barriers. This capability may
-be turned off using this pragma in cases where it is known not to be
-required.
-
-The placement and scope rules for this pragma are the same as those
-for @code{pragma Suppress}. In particular it can be used as a
-configuration  pragma, or in a declaration sequence where it applies
-till the end of the scope. If an @code{Entity} argument is present,
+handling, e.g. the generation of memory barriers. This synchronization
+is performed by default, but can be turned off using pragma
+@code{Disable_Atomic_Synchronization}.
+The @code{Enable_Atomic_Synchronization} pragma turns it back on.
+
+The placement and scope rules for these pragmas are the same as those
+for @code{pragma Suppress}. In particular they can be used as
+configuration pragmas, or in a declaration sequence where they apply
+until the end of the scope. If an @code{Entity} argument is present,
 the action applies only to that entity.
 
 @node Pragma Dispatching_Domain,Pragma Effective_Reads,Pragma 
Disable_Atomic_Synchronization,Implementation Defined Pragmas
@@ -3417,20 +3420,8 @@ Syntax:
 pragma Enable_Atomic_Synchronization [(Entity)];
 @end example
 
-Ada requires that accesses (reads or writes) of an atomic variable be
-regarded as synchronization points in the case of multiple tasks.
-Particularly in the case of multi-processors this may require special
-handling, e.g. the generation of memory barriers. This synchronization
-is performed by default, but can be turned off using
-@code{pragma Disable_Atomic_Synchronization}. The
-@code{Enable_Atomic_Synchronization} pragma can be used to turn
-it back on.
-
-The placement and scope rules for this pragma are the same as those
-for @code{pragma Unsuppress}. In particular it can be used as a
-configuration  pragma, or in a declaration sequence where it applies
-till the end of the scope. If an @code{Entity} argument is present,
-the action applies only to that entity.
+Reenables atomic synchronization; see @code{pragma 
Disable_Atomic_Synchronization}
+for details.
 
 @node Pragma Exceptional_Cases,Pragma Export_Function,Pragma 
Enable_Atomic_Synchronization,Implementation Defined Pragmas
 @anchor{gnat_rm/implementation_defined_pragmas 
pragma-exceptional-cases}@anchor{61}
@@ -16815,12 +16806,12 @@ via compiler switches such as “-gnata”.
 “Implementation-defined check names.  See 11.5(27).”
 @end itemize
 
-The implementation defined check names include Alignment_Check,
-Atomic_Synchronization, Container_Checks, Duplicated_Tag_Check,
-Predicate_Check, Raise_Check, Tampering_Check, and Validity_Check.
-In addition, a user program can add implementation-defined check
-names by means of the pragma Check_Name. See the description of
-pragma @code{Suppress} for full details.
+The implementation-defined check names include Alignment_Check,
+Container_Checks, Duplicated_Tag_Check, Predicate_Check,
+Raise_Check, Tampering_Check, and Validity_Check. In addition, a
+user program can add implementation-defined check names by means
+of the pragma Check_Name. See the description of pragma
+@code{Suppress} for details.
 
 
 @itemize *
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index 18976805005..0414a2170cd 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -19,7 +19,7 @@
 
 @copying
 @quotation
-GNAT User's Guide for Native Platforms , Nov 08, 2024
+GNAT User's Guide for Native Platforms , Nov 18, 2024
 
 AdaCore
 
@@ -14249,10 +14249,8 @@ the condition being checked is true, which can result 
in erroneous
 execution if that assumption is wrong.
 
 The checks subject to suppression include all the checks defined by the Ada
-standard, the additional implementation defined checks @code{Alignment_Check},
-@code{Duplicated_Tag_Check}, @code{Predicate_Check}, @code{Container_Checks}, 
@code{Tampering_Check},
-and @code{Validity_Check}, as well as any checks introduced using @code{pragma 
Check_Name}.
-Note that @code{Atomic_Synchronization} is not automatically suppressed by use 
of this option.
+standard, as well as all implementation-defined checks,
+including any checks introduced using @code{pragma Check_Name}.
 
 If the code depends on certain checks being active, you can use
 pragma @code{Unsuppress} either as a configuration pragma or as
@@ -29841,8 +29839,8 @@ to permit their use in free software.
 
 @printindex ge
 
-@anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{   
                           }
 @anchor{d2}@w{                              }
+@anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{   
                           }
 
 @c %**end of body
 @bye
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index ef903965232..484c7538bbf 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -9020,8 +9020,8 @@ package body Sem_Prag is
          Check_No_Identifiers;
          Check_At_Most_N_Arguments (1);
 
-         --  Modeled internally as
-         --    pragma Suppress/Unsuppress (Atomic_Synchronization [,Entity])
+         --  Implemented internally as
+         --    pragma Suppress/Unsuppress (_Atomic_Synchronization [,Entity])
 
          Rewrite (N,
            Make_Pragma (Loc,
@@ -9029,7 +9029,7 @@ package body Sem_Prag is
              Pragma_Argument_Associations => New_List (
                Make_Pragma_Argument_Association (Loc,
                  Expression =>
-                   Make_Identifier (Loc, Name_Atomic_Synchronization)))));
+                   Make_Identifier (Loc, Name_uAtomic_Synchronization)))));
 
          if Present (Arg1) then
             Append_To (Pragma_Argument_Associations (N), New_Copy (Arg1));
@@ -11416,23 +11416,16 @@ package body Sem_Prag is
                --  not a real check.
 
                for J in Scope_Suppress.Suppress'Range loop
-                  if J /= Elaboration_Check
-                       and then
-                     J /= Atomic_Synchronization
-                  then
+                  if J not in Elaboration_Check | Atomic_Synchronization then
                      Scope_Suppress.Suppress (J) := Suppress_Case;
                   end if;
                end loop;
 
             --  If not All_Checks, and predefined check, then set appropriate
             --  scope entry. Note that we will set Elaboration_Check if this
-            --  is explicitly specified. Atomic_Synchronization is allowed
-            --  only if internally generated and entity is atomic.
+            --  is explicitly specified.
 
-            elsif C in Predefined_Check_Id
-              and then (not Comes_From_Source (N)
-                         or else C /= Atomic_Synchronization)
-            then
+            elsif C in Predefined_Check_Id then
                Scope_Suppress.Suppress (C) := Suppress_Case;
             end if;
 
diff --git a/gcc/ada/snames.ads-tmpl b/gcc/ada/snames.ads-tmpl
index 3281b6f12f8..76527806efe 100644
--- a/gcc/ada/snames.ads-tmpl
+++ b/gcc/ada/snames.ads-tmpl
@@ -1226,15 +1226,15 @@ package Snames is
 
    --  Names of recognized checks for pragma Suppress
 
-   --  Note: the name Atomic_Synchronization can only be specified internally
-   --  as a result of using pragma Enable/Disable_Atomic_Synchronization.
+   --  Note: the name _Atomic_Synchronization is used only internally
+   --  as a result of using pragmas Disable/Enable_Atomic_Synchronization.
 
    First_Check_Name                    : constant Name_Id := N + $;
    Name_Access_Check                   : constant Name_Id := N + $;
    Name_Accessibility_Check            : constant Name_Id := N + $;
    Name_Alignment_Check                : constant Name_Id := N + $; -- GNAT
    Name_Allocation_Check               : constant Name_Id := N + $;
-   Name_Atomic_Synchronization         : constant Name_Id := N + $; -- GNAT
+   Name_uAtomic_Synchronization        : constant Name_Id := N + $; -- GNAT
    Name_Characters_Assertion_Check     : constant Name_Id := N + $;
    Name_Containers_Assertion_Check     : constant Name_Id := N + $;
    Name_Discriminant_Check             : constant Name_Id := N + $;
diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb
index 9b5dde7c8d8..2b56e64383d 100644
--- a/gcc/ada/switch-c.adb
+++ b/gcc/ada/switch-c.adb
@@ -1154,9 +1154,7 @@ package body Switch.C is
                   --  check.
 
                   for J in Suppress_Options.Suppress'Range loop
-                     if J /= Elaboration_Check
-                          and then
-                        J /= Atomic_Synchronization
+                     if J not in Elaboration_Check | Atomic_Synchronization
                      then
                         Suppress_Options.Suppress (J) := True;
                      end if;
diff --git a/gcc/ada/targparm.ads b/gcc/ada/targparm.ads
index 323a41dcc8b..4a7f65b7c54 100644
--- a/gcc/ada/targparm.ads
+++ b/gcc/ada/targparm.ads
@@ -325,14 +325,14 @@ package Targparm is
    Atomic_Sync_Default_On_Target : Boolean := True;
    --  Access to atomic variables requires memory barrier synchronization in
    --  the general case to ensure proper behavior when such accesses are used
-   --  on a multi-processor to synchronize tasks (e.g. by using spin locks).
+   --  on a multiprocessor to synchronize tasks (e.g. by using spin locks).
    --  The setting of this flag determines the default behavior. Normally this
    --  is True, which will mean that appropriate synchronization instructions
    --  are generated by default. If it is False, then the default will be that
    --  these synchronization instructions are not generated. This may be a more
    --  appropriate default in some cases, e.g. on embedded targets which do not
-   --  allow the possibility of multi-processors. The default can be overridden
-   --  using pragmas Enable/Disable_Atomic_Synchronization and also by use of
+   --  allow the possibility of multiprocessors. The default can be overridden
+   --  using pragmas Disable/Enable_Atomic_Synchronization and also by use of
    --  the corresponding debug flags -gnatd.e and -gnatd.d.
 
    Support_Aggregates_On_Target : Boolean := True;
diff --git a/gcc/ada/types.ads b/gcc/ada/types.ads
index bc466f67f9a..43dad13f86e 100644
--- a/gcc/ada/types.ads
+++ b/gcc/ada/types.ads
@@ -707,8 +707,7 @@ package Types is
    Tasking_Check              : constant := 28;
    Raise_Check                : constant := 29;
    --  Values used to represent individual predefined checks (including the
-   --  setting of Atomic_Synchronization, which is implemented internally using
-   --  a "check" whose name is Atomic_Synchronization).
+   --  pseudo-check _Atomic_Synchronization).
 
    All_Checks : constant := 30;
    --  Value used to represent All_Checks value
-- 
2.43.0

Reply via email to