aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_util.adb
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2022-05-26 15:02:01 +0000
committerPierre-Marie de Rodat <derodat@adacore.com>2022-07-04 07:45:57 +0000
commit78f13b008ab58794057847a74903ee4569829d80 (patch)
tree47c9f8365e4c74f6bd251424084d409f0edbe251 /gcc/ada/exp_util.adb
parent1fde86bba55ea61b56f79798c6ac4cc6808e51a1 (diff)
downloadgcc-78f13b008ab58794057847a74903ee4569829d80.zip
gcc-78f13b008ab58794057847a74903ee4569829d80.tar.gz
gcc-78f13b008ab58794057847a74903ee4569829d80.tar.bz2
[Ada] Tech debt: Remove code duplication
This patch corrects removes some code duplication within the GNAT compiler. gcc/ada/ * exp_util.adb (Remove_Side_Effects): Combine identical branches. * sem_attr.adb (Analyze_Attribute): Combine identical cases Attribute_Has_Same_Storage and Attribute_Overlaps_Storage. * sem_prag.adb (Check_Role): Combine E_Out_Parameter case with general case for parameters. * sem_util.adb (Accessibility_Level): Combine identical branches. * sprint.adb (Sprint_Node_Actual): Combine cases for N_Real_Range_Specification and N_Signed_Integer_Type_Definition.
Diffstat (limited to 'gcc/ada/exp_util.adb')
-rw-r--r--gcc/ada/exp_util.adb34
1 files changed, 13 insertions, 21 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 2a7afd4..eaf7ebf 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -12017,31 +12017,23 @@ package body Exp_Util is
-- renaming is handled by the front end, as the back end may balk at
-- the nonstandard representation (see Evaluation_Required in Exp_Ch8).
- elsif Nkind (Exp) in N_Indexed_Component | N_Selected_Component
- and then Has_Non_Standard_Rep (Etype (Prefix (Exp)))
- then
- Def_Id := Build_Temporary (Loc, 'R', Exp);
- Res := New_Occurrence_Of (Def_Id, Loc);
-
- Insert_Action (Exp,
- Make_Object_Renaming_Declaration (Loc,
- Defining_Identifier => Def_Id,
- Subtype_Mark => New_Occurrence_Of (Exp_Type, Loc),
- Name => Relocate_Node (Exp)));
+ elsif (Nkind (Exp) in N_Indexed_Component | N_Selected_Component
+ and then Has_Non_Standard_Rep (Etype (Prefix (Exp))))
- -- For an expression that denotes a name, we can use a renaming scheme.
- -- This is needed for correctness in the case of a volatile object of
- -- a nonvolatile type because the Make_Reference call of the "default"
- -- approach would generate an illegal access value (an access value
- -- cannot designate such an object - see Analyze_Reference).
+ -- For an expression that denotes a name, we can use a renaming
+ -- scheme. This is needed for correctness in the case of a volatile
+ -- object of a nonvolatile type because the Make_Reference call of the
+ -- "default" approach would generate an illegal access value (an
+ -- access value cannot designate such an object - see
+ -- Analyze_Reference).
- elsif Is_Name_Reference (Exp)
+ or else (Is_Name_Reference (Exp)
- -- We skip using this scheme if we have an object of a volatile
- -- type and we do not have Name_Req set true (see comments for
- -- Side_Effect_Free).
+ -- We skip using this scheme if we have an object of a volatile
+ -- type and we do not have Name_Req set true (see comments for
+ -- Side_Effect_Free).
- and then (Name_Req or else not Treat_As_Volatile (Exp_Type))
+ and then (Name_Req or else not Treat_As_Volatile (Exp_Type)))
then
Def_Id := Build_Temporary (Loc, 'R', Exp);
Res := New_Occurrence_Of (Def_Id, Loc);