public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1513] [Ada] Wrong reference to System.Tasking in expanded code
@ 2021-06-16  8:45 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-16  8:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:37cd8d97f3aa779197eb103d1e4b4d0ac63adc4a

commit r12-1513-g37cd8d97f3aa779197eb103d1e4b4d0ac63adc4a
Author: Arnaud Charlet <charlet@adacore.com>
Date:   Sun Feb 28 08:25:42 2021 -0500

    [Ada] Wrong reference to System.Tasking in expanded code
    
    gcc/ada/
    
            * rtsfind.ads, libgnarl/s-taskin.ads, exp_ch3.adb, exp_ch4.adb,
            exp_ch6.adb, exp_ch9.adb, sem_ch6.adb: Move master related
            entities to the expander directly.

Diff:
---
 gcc/ada/exp_ch3.adb           |  9 ++++-----
 gcc/ada/exp_ch4.adb           |  4 ++--
 gcc/ada/exp_ch6.adb           |  2 +-
 gcc/ada/exp_ch9.adb           | 39 +++++++++++++--------------------------
 gcc/ada/libgnarl/s-taskin.ads |  3 +++
 gcc/ada/rtsfind.ads           | 16 ++++------------
 gcc/ada/sem_ch6.adb           |  2 +-
 7 files changed, 28 insertions(+), 47 deletions(-)

diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 4de75a650a2..23b5b348a50 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -1696,8 +1696,7 @@ package body Exp_Ch3 is
 
       if Has_Task (Full_Type) then
          if Restriction_Active (No_Task_Hierarchy) then
-            Append_To (Args,
-              New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc));
+            Append_To (Args, Make_Integer_Literal (Loc, Library_Task_Level));
          else
             Append_To (Args, Make_Identifier (Loc, Name_uMaster));
          end if;
@@ -2218,8 +2217,8 @@ package body Exp_Ch3 is
 
          if Has_Task (Rec_Type) then
             if Restriction_Active (No_Task_Hierarchy) then
-               Append_To (Args,
-                 New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc));
+               Append_To
+                 (Args, Make_Integer_Literal (Loc, Library_Task_Level));
             else
                Append_To (Args, Make_Identifier (Loc, Name_uMaster));
             end if;
@@ -9071,7 +9070,7 @@ package body Exp_Ch3 is
              Defining_Identifier =>
                Make_Defining_Identifier (Loc, Name_uMaster),
              Parameter_Type      =>
-               New_Occurrence_Of (RTE (RE_Master_Id), Loc)));
+               New_Occurrence_Of (Standard_Integer, Loc)));
 
          Set_Has_Master_Entity (Proc_Id);
 
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 81f83872261..5b3a11677db 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -5193,8 +5193,8 @@ package body Exp_Ch4 is
                   end if;
 
                   if Restriction_Active (No_Task_Hierarchy) then
-                     Append_To (Args,
-                       New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc));
+                     Append_To
+                       (Args, Make_Integer_Literal (Loc, Library_Task_Level));
                   else
                      Append_To (Args,
                        New_Occurrence_Of
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 919e174aec8..b5d77bdcf7c 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -602,7 +602,7 @@ package body Exp_Ch6 is
       --  Use a dummy _master actual in case of No_Task_Hierarchy
 
       if Restriction_Active (No_Task_Hierarchy) then
-         Actual := New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc);
+         Actual := Make_Integer_Literal (Loc, Library_Task_Level);
 
       --  In the case where we use the master associated with an access type,
       --  the actual is an entity and requires an explicit reference.
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index fa2d84d089c..3948b6a51a3 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -1756,34 +1756,21 @@ package body Exp_Ch9 is
       --  Generate a dummy master if tasks or tasking hierarchies are
       --  prohibited.
 
-      --    _Master : constant Master_Id := 3;
+      --    _Master : constant Integer := Library_Task_Level;
 
       if not Tasking_Allowed
         or else Restrictions.Set (No_Task_Hierarchy)
         or else not RTE_Available (RE_Current_Master)
       then
-         declare
-            Expr : Node_Id;
-
-         begin
-            --  RE_Library_Task_Level is not always available in configurable
-            --  RunTime
-
-            if not RTE_Available (RE_Library_Task_Level) then
-               Expr := Make_Integer_Literal (Loc, Uint_3);
-            else
-               Expr := New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc);
-            end if;
-
-            Master_Decl :=
-              Make_Object_Declaration (Loc,
-                Defining_Identifier =>
-                  Make_Defining_Identifier (Loc, Name_uMaster),
-                Constant_Present    => True,
-                Object_Definition   =>
-                  New_Occurrence_Of (Standard_Integer, Loc),
-                Expression          => Expr);
-         end;
+         Master_Decl :=
+           Make_Object_Declaration (Loc,
+             Defining_Identifier =>
+               Make_Defining_Identifier (Loc, Name_uMaster),
+             Constant_Present    => True,
+             Object_Definition   =>
+               New_Occurrence_Of (Standard_Integer, Loc),
+             Expression          =>
+               Make_Integer_Literal (Loc, Library_Task_Level));
 
       --  Generate:
       --    _master : constant Integer := Current_Master.all;
@@ -3628,7 +3615,8 @@ package body Exp_Ch9 is
       Master_Decl :=
         Make_Object_Renaming_Declaration (Loc,
           Defining_Identifier => Master_Id,
-          Subtype_Mark        => New_Occurrence_Of (RTE (RE_Master_Id), Loc),
+          Subtype_Mark        =>
+            New_Occurrence_Of (Standard_Integer, Loc),
           Name                => Make_Identifier (Loc, Name_uMaster));
 
       Insert_Action (Context, Master_Decl);
@@ -14710,8 +14698,7 @@ package body Exp_Ch9 is
          if Restriction_Active (No_Task_Hierarchy) = False then
             Append_To (Args, Make_Identifier (Loc, Name_uMaster));
          else
-            Append_To (Args,
-              New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc));
+            Append_To (Args, Make_Integer_Literal (Loc, Library_Task_Level));
          end if;
       end if;
 
diff --git a/gcc/ada/libgnarl/s-taskin.ads b/gcc/ada/libgnarl/s-taskin.ads
index f095c663b70..5c03829f1e9 100644
--- a/gcc/ada/libgnarl/s-taskin.ads
+++ b/gcc/ada/libgnarl/s-taskin.ads
@@ -773,6 +773,9 @@ package System.Tasking is
    Environment_Task_Level : constant Master_Level := 1;
    Independent_Task_Level : constant Master_Level := 2;
    Library_Task_Level     : constant Master_Level := 3;
+   --  Note that the value of Library_Task_Level is also hard coded in the
+   --  compiler, see Rtsfind.Library_Task_Level. The two should be kept in
+   --  sync.
 
    -------------------
    -- Priority info --
diff --git a/gcc/ada/rtsfind.ads b/gcc/ada/rtsfind.ads
index 39e4fb28953..ef17cf25301 100644
--- a/gcc/ada/rtsfind.ads
+++ b/gcc/ada/rtsfind.ads
@@ -29,6 +29,7 @@
 --  not been explicitly With'ed.
 
 with Types; use Types;
+with Uintp; use Uintp;
 
 package Rtsfind is
 
@@ -1975,11 +1976,6 @@ package Rtsfind is
      RE_Conditional_Call,                -- System.Tasking
      RE_Asynchronous_Call,               -- System.Tasking
 
-     RE_Foreign_Task_Level,              -- System.Tasking
-     RE_Environment_Task_Level,          -- System.Tasking
-     RE_Independent_Task_Level,          -- System.Tasking
-     RE_Library_Task_Level,              -- System.Tasking
-
      RE_Ada_Task_Control_Block,          -- System.Tasking
 
      RE_Task_List,                       -- System.Tasking
@@ -1996,7 +1992,6 @@ package Rtsfind is
      RE_Task_Entry_Index,                -- System.Tasking
      RE_Self,                            -- System.Tasking
 
-     RE_Master_Id,                       -- System.Tasking
      RE_Unspecified_Priority,            -- System.Tasking
 
      RE_Activation_Chain,                -- System.Tasking
@@ -3665,11 +3660,6 @@ package Rtsfind is
      RE_Conditional_Call                 => System_Tasking,
      RE_Asynchronous_Call                => System_Tasking,
 
-     RE_Foreign_Task_Level               => System_Tasking,
-     RE_Environment_Task_Level           => System_Tasking,
-     RE_Independent_Task_Level           => System_Tasking,
-     RE_Library_Task_Level               => System_Tasking,
-
      RE_Ada_Task_Control_Block           => System_Tasking,
 
      RE_Task_List                        => System_Tasking,
@@ -3686,7 +3676,6 @@ package Rtsfind is
      RE_Task_Entry_Index                 => System_Tasking,
      RE_Self                             => System_Tasking,
 
-     RE_Master_Id                        => System_Tasking,
      RE_Unspecified_Priority             => System_Tasking,
 
      RE_Activation_Chain                 => System_Tasking,
@@ -3994,6 +3983,9 @@ package Rtsfind is
       System_Unsigned_Types   => True,
       others                  => False);
 
+   Library_Task_Level : constant Uint := Uint_3;
+   --  Corresponds to System.Tasking.Library_Task_Level
+
    -----------------
    -- Subprograms --
    -----------------
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index ed6b09aac2d..d707b0e15d8 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -9042,7 +9042,7 @@ package body Sem_Ch6 is
             if Needs_BIP_Task_Actuals (E) then
                Discard :=
                  Add_Extra_Formal
-                   (E, RTE (RE_Master_Id),
+                   (E, Standard_Integer,
                     E, BIP_Formal_Suffix (BIP_Task_Master));
 
                Set_Has_Master_Entity (E);


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16  8:45 [gcc r12-1513] [Ada] Wrong reference to System.Tasking in expanded code 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).