]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Simplify check for type without stream operations
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 19 Mar 2024 10:22:40 +0000 (11:22 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 10 Jun 2024 09:03:58 +0000 (11:03 +0200)
Recursive routine Type_Without_Stream_Operation was checking restriction
No_Default_Stream_Attributes at every call, which was confusing and
inefficient.

This routine is only called from the places: Check_Stream_Attribute,
which already checks if this restriction is active, and
Stream_Operation_OK, where we add such a check.

Cleanup related to extending the use of No_Streams restriction.

gcc/ada/

* exp_ch3.adb (Stream_Operation_OK): Check restriction
No_Default_Stream_Attributes before call to
Type_Without_Stream_Operation.
* sem_util.adb (Type_Without_Stream_Operation): Remove static
condition from recursive routine

gcc/ada/exp_ch3.adb
gcc/ada/sem_util.adb

index 8ddae1eb1be31d1366deb8d4e1ea47b3720035e1..f9dd0914111e1e1c7c849e5ad1b6a6e8961877e7 100644 (file)
@@ -12912,7 +12912,9 @@ package body Exp_Ch3 is
         and then No (No_Tagged_Streams_Pragma (Typ))
         and then not No_Run_Time_Mode
         and then RTE_Available (RE_Tag)
-        and then No (Type_Without_Stream_Operation (Typ))
+        and then
+          (not Restriction_Active (No_Default_Stream_Attributes)
+             or else No (Type_Without_Stream_Operation (Typ)))
         and then RTE_Available (RE_Root_Stream_Type);
    end Stream_Operation_OK;
 
index 15994b4d1e9c5c39dfc94d8c86bcc7fabfbd329e..241be3d2957168e127854da1f4a3a552ce2d0f52 100644 (file)
@@ -28557,10 +28557,6 @@ package body Sem_Util is
       Op_Missing : Boolean;
 
    begin
-      if not Restriction_Active (No_Default_Stream_Attributes) then
-         return Empty;
-      end if;
-
       if Is_Elementary_Type (T) then
          if Op = TSS_Null then
             Op_Missing :=