aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_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/sem_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/sem_util.adb')
-rw-r--r--gcc/ada/sem_util.adb54
1 files changed, 20 insertions, 34 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index addad83..1b0b39b 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -798,44 +798,30 @@ package body Sem_Util is
-- in effect we treat discriminant components as regular
-- components.
- elsif Nkind (E) = N_Selected_Component
- and then Ekind (Etype (E)) = E_Anonymous_Access_Type
- and then Ekind (Etype (Pre)) /= E_Anonymous_Access_Type
- and then (not (Nkind (Selector_Name (E)) in N_Has_Entity
- and then Ekind (Entity (Selector_Name (E)))
- = E_Discriminant)
-
- -- The alternative accessibility models both treat
- -- discriminants as regular components.
-
- or else (No_Dynamic_Accessibility_Checks_Enabled (E)
- and then Allow_Alt_Model))
- then
- -- When restriction No_Dynamic_Accessibility_Checks is active
- -- and -gnatd_b set, the level is that of the designated type.
-
- if Allow_Alt_Model
- and then No_Dynamic_Accessibility_Checks_Enabled (E)
- and then Debug_Flag_Underscore_B
- then
- return Make_Level_Literal
- (Typ_Access_Level (Etype (E)));
- end if;
+ elsif
+ (Nkind (E) = N_Selected_Component
+ and then Ekind (Etype (E)) = E_Anonymous_Access_Type
+ and then Ekind (Etype (Pre)) /= E_Anonymous_Access_Type
+ and then (not (Nkind (Selector_Name (E)) in N_Has_Entity
+ and then Ekind (Entity (Selector_Name (E)))
+ = E_Discriminant)
- -- Otherwise proceed normally
+ -- The alternative accessibility models both treat
+ -- discriminants as regular components.
- return Make_Level_Literal
- (Typ_Access_Level (Etype (Prefix (E))));
+ or else (No_Dynamic_Accessibility_Checks_Enabled (E)
+ and then Allow_Alt_Model)))
- -- Similar to the previous case - arrays featuring components of
- -- anonymous access components get their corresponding level from
- -- their containing type's declaration.
+ -- Arrays featuring components of anonymous access components
+ -- get their corresponding level from their containing type's
+ -- declaration.
- elsif Nkind (E) = N_Indexed_Component
- and then Ekind (Etype (E)) = E_Anonymous_Access_Type
- and then Ekind (Etype (Pre)) in Array_Kind
- and then Ekind (Component_Type (Base_Type (Etype (Pre))))
- = E_Anonymous_Access_Type
+ or else
+ (Nkind (E) = N_Indexed_Component
+ and then Ekind (Etype (E)) = E_Anonymous_Access_Type
+ and then Ekind (Etype (Pre)) in Array_Kind
+ and then Ekind (Component_Type (Base_Type (Etype (Pre))))
+ = E_Anonymous_Access_Type)
then
-- When restriction No_Dynamic_Accessibility_Checks is active
-- and -gnatd_b set, the level is that of the designated type.