[gcc r15-1138] ada: Simplify check for type without stream operations
Marc Poulhi?s
dkm@gcc.gnu.org
Mon Jun 10 09:07:39 GMT 2024
https://gcc.gnu.org/g:025fd3eabc12a5b5ee63b607a2fa26aafb3a39b4
commit r15-1138-g025fd3eabc12a5b5ee63b607a2fa26aafb3a39b4
Author: Piotr Trojanek <trojanek@adacore.com>
Date: Tue Mar 19 11:22:40 2024 +0100
ada: Simplify check for type without stream operations
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
Diff:
---
gcc/ada/exp_ch3.adb | 4 +++-
gcc/ada/sem_util.adb | 4 ----
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 8ddae1eb1be..f9dd0914111 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -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;
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 15994b4d1e9..241be3d2957 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -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 :=
More information about the Gcc-cvs
mailing list