]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Remove duplicated code for detecting enabled pragmas
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 4 Mar 2022 16:46:30 +0000 (17:46 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 16 May 2022 08:42:02 +0000 (08:42 +0000)
Routines Is_Enabled and Is_Enabled_Pragma are identical (except for
comments); remove this duplication.

Cleanup related to handling of volatile refinement aspects in SPARK;
behaviour is unaffected.

gcc/ada/

* sem_util.adb (Is_Enabled): Remove; use Is_Enabled_Pragma
instead.

gcc/ada/sem_util.adb

index b7ebd4abbaac5e608d8640e53d89e88ae1ab8215..d53c43569760a0c4e6c499083bfbd1c2b778e387 100644 (file)
@@ -12632,44 +12632,6 @@ package body Sem_Util is
       function Type_Or_Variable_Has_Enabled_Property
         (Item_Id : Entity_Id) return Boolean
       is
-         function Is_Enabled (Prag : Node_Id) return Boolean;
-         --  Determine whether property pragma Prag (if present) denotes an
-         --  enabled property.
-
-         ----------------
-         -- Is_Enabled --
-         ----------------
-
-         function Is_Enabled (Prag : Node_Id) return Boolean is
-            Arg1 : Node_Id;
-
-         begin
-            if Present (Prag) then
-               Arg1 := First (Pragma_Argument_Associations (Prag));
-
-               --  The pragma has an optional Boolean expression, the related
-               --  property is enabled only when the expression evaluates to
-               --  True.
-
-               if Present (Arg1) then
-                  return Is_True (Expr_Value (Get_Pragma_Arg (Arg1)));
-
-               --  Otherwise the lack of expression enables the property by
-               --  default.
-
-               else
-                  return True;
-               end if;
-
-            --  The property was never set in the first place
-
-            else
-               return False;
-            end if;
-         end Is_Enabled;
-
-         --  Local variables
-
          AR : constant Node_Id :=
                 Get_Pragma (Item_Id, Pragma_Async_Readers);
          AW : constant Node_Id :=
@@ -12683,8 +12645,6 @@ package body Sem_Util is
            Is_Derived_Type (Item_Id)
            and then Is_Effectively_Volatile (Etype (Base_Type (Item_Id)));
 
-      --  Start of processing for Type_Or_Variable_Has_Enabled_Property
-
       begin
          --  A non-effectively volatile object can never possess external
          --  properties.
@@ -12699,16 +12659,16 @@ package body Sem_Util is
          --  missing altogether.
 
          elsif Property = Name_Async_Readers    and then Present (AR) then
-            return Is_Enabled (AR);
+            return Is_Enabled_Pragma (AR);
 
          elsif Property = Name_Async_Writers    and then Present (AW) then
-            return Is_Enabled (AW);
+            return Is_Enabled_Pragma (AW);
 
          elsif Property = Name_Effective_Reads  and then Present (ER) then
-            return Is_Enabled (ER);
+            return Is_Enabled_Pragma (ER);
 
          elsif Property = Name_Effective_Writes and then Present (EW) then
-            return Is_Enabled (EW);
+            return Is_Enabled_Pragma (EW);
 
          --  If other properties are set explicitly, then this one is set
          --  implicitly to False, except in the case of a derived type
This page took 0.090711 seconds and 5 git commands to generate.