aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2024-02-05 19:41:50 +0100
committerMarc Poulhiès <poulhies@adacore.com>2024-06-10 11:03:59 +0200
commit2d20aaaa8a3cb807431fcd74bec02967fcd60995 (patch)
treea215ff59281f5f2a9f4e244b9042028cf3b99b3a /gcc
parent3da7847e82e8416af107a64fa980ae0f7cf0a110 (diff)
downloadgcc-2d20aaaa8a3cb807431fcd74bec02967fcd60995.zip
gcc-2d20aaaa8a3cb807431fcd74bec02967fcd60995.tar.gz
gcc-2d20aaaa8a3cb807431fcd74bec02967fcd60995.tar.bz2
ada: Cleanup repeated code in expansion of stream attributes
In expansion of various attributes, in particular for the Input/Output and Read/Write attributes, we can use constants that are already used for expansion of many other attributes. gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference): Use constants declared at the beginning of subprogram; tune layout. * exp_ch3.adb (Predefined_Primitive_Bodies): Tune layout.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_attr.adb36
-rw-r--r--gcc/ada/exp_ch3.adb3
2 files changed, 16 insertions, 23 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 6942814..0349db2 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -179,7 +179,6 @@ package body Exp_Attr is
-- * Rec_Typ - the record type whose internals are to be validated
function Default_Streaming_Unavailable (Typ : Entity_Id) return Boolean;
- --
-- In most cases, references to unavailable streaming attributes
-- are rejected at compile time. In some obscure cases involving
-- generics and formal derived types, the problem is dealt with at runtime.
@@ -4091,10 +4090,8 @@ package body Exp_Attr is
----------------------
when Attribute_Has_Same_Storage => Has_Same_Storage : declare
- Loc : constant Source_Ptr := Sloc (N);
-
- X : constant Node_Id := Prefix (N);
- Y : constant Node_Id := First (Expressions (N));
+ X : constant Node_Id := Pref;
+ Y : constant Node_Id := First (Exprs);
-- The arguments
X_Addr : Node_Id;
@@ -4363,7 +4360,7 @@ package body Exp_Attr is
if Restriction_Active (No_Streams) then
Rewrite (N,
- Make_Raise_Program_Error (Sloc (N),
+ Make_Raise_Program_Error (Loc,
Reason => PE_Stream_Operation_Not_Allowed));
Set_Etype (N, B_Type);
return;
@@ -4415,7 +4412,7 @@ package body Exp_Attr is
-- case where a No_Streams restriction is active.
Rewrite (N,
- Make_Raise_Program_Error (Sloc (N),
+ Make_Raise_Program_Error (Loc,
Reason => PE_Stream_Operation_Not_Allowed));
Set_Etype (N, B_Type);
return;
@@ -5295,10 +5292,8 @@ package body Exp_Attr is
----------------------
when Attribute_Overlaps_Storage => Overlaps_Storage : declare
- Loc : constant Source_Ptr := Sloc (N);
- X : constant Node_Id := Prefix (N);
- Y : constant Node_Id := First (Expressions (N));
-
+ X : constant Node_Id := Pref;
+ Y : constant Node_Id := First (Exprs);
-- The arguments
X_Addr, Y_Addr : Node_Id;
@@ -5451,7 +5446,7 @@ package body Exp_Attr is
if Restriction_Active (No_Streams) then
Rewrite (N,
- Make_Raise_Program_Error (Sloc (N),
+ Make_Raise_Program_Error (Loc,
Reason => PE_Stream_Operation_Not_Allowed));
Set_Etype (N, Standard_Void_Type);
return;
@@ -5505,7 +5500,7 @@ package body Exp_Attr is
-- case where a No_Streams restriction is active.
Rewrite (N,
- Make_Raise_Program_Error (Sloc (N),
+ Make_Raise_Program_Error (Loc,
Reason => PE_Stream_Operation_Not_Allowed));
Set_Etype (N, Standard_Void_Type);
return;
@@ -6180,10 +6175,9 @@ package body Exp_Attr is
when Attribute_Reduce =>
declare
- Loc : constant Source_Ptr := Sloc (N);
- E1 : constant Node_Id := First (Expressions (N));
- E2 : constant Node_Id := Next (E1);
- Bnn : constant Entity_Id := Make_Temporary (Loc, 'B', N);
+ E1 : constant Node_Id := First (Exprs);
+ E2 : constant Node_Id := Next (E1);
+ Bnn : constant Entity_Id := Make_Temporary (Loc, 'B', N);
Accum_Typ : Entity_Id := Empty;
New_Loop : Node_Id;
@@ -6381,7 +6375,7 @@ package body Exp_Attr is
if Restriction_Active (No_Streams) then
Rewrite (N,
- Make_Raise_Program_Error (Sloc (N),
+ Make_Raise_Program_Error (Loc,
Reason => PE_Stream_Operation_Not_Allowed));
Set_Etype (N, B_Type);
return;
@@ -6453,7 +6447,7 @@ package body Exp_Attr is
-- case where a No_Streams restriction is active.
Rewrite (N,
- Make_Raise_Program_Error (Sloc (N),
+ Make_Raise_Program_Error (Loc,
Reason => PE_Stream_Operation_Not_Allowed));
Set_Etype (N, B_Type);
return;
@@ -8096,7 +8090,7 @@ package body Exp_Attr is
if Restriction_Active (No_Streams) then
Rewrite (N,
- Make_Raise_Program_Error (Sloc (N),
+ Make_Raise_Program_Error (Loc,
Reason => PE_Stream_Operation_Not_Allowed));
Set_Etype (N, U_Type);
return;
@@ -8150,7 +8144,7 @@ package body Exp_Attr is
-- case where a No_Streams restriction is active.
Rewrite (N,
- Make_Raise_Program_Error (Sloc (N),
+ Make_Raise_Program_Error (Loc,
Reason => PE_Stream_Operation_Not_Allowed));
Set_Etype (N, U_Type);
return;
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index f9dd091..f03cda6 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -12655,8 +12655,7 @@ package body Exp_Ch3 is
and then Stream_Operation_OK (Tag_Typ, TSS_Stream_Input)
and then No (TSS (Tag_Typ, TSS_Stream_Input))
then
- Build_Record_Or_Elementary_Input_Function
- (Tag_Typ, Decl, Ent);
+ Build_Record_Or_Elementary_Input_Function (Tag_Typ, Decl, Ent);
Append_To (Res, Decl);
end if;