[COMMITTED,15/30] ada: Remove redundant conditions from freezing code
Commit Message
From: Piotr Trojanek <trojanek@adacore.com>
Code cleanup; behavior is unaffected.
gcc/ada/
* freeze.adb (Check_Current_Instance): This routine is only called
with parameter E being a type entity, so there is no need to check
for types just before the equality with E.
* sem_ch13.adb (Analyze_Aspect_Specifications): Regroup condition
to avoid unnecessary evaluation.
(Check_Aspect_At_End_Of_Declarations): If In_Instance is true,
then the routine exits early.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/freeze.adb | 1 -
gcc/ada/sem_ch13.adb | 14 +++++++-------
2 files changed, 7 insertions(+), 8 deletions(-)
@@ -3086,7 +3086,6 @@ package body Freeze is
when N_Attribute_Reference =>
if Attribute_Name (N) in Name_Access | Name_Unchecked_Access
and then Is_Entity_Name (Prefix (N))
- and then Is_Type (Entity (Prefix (N)))
and then Entity (Prefix (N)) = E
then
if Ada_Version < Ada_2012 then
@@ -4086,12 +4086,12 @@ package body Sem_Ch13 is
Error_Msg_N ("aspect% cannot apply to subtype", Id);
goto Continue;
- elsif A_Id = Aspect_Default_Value
- and then not Is_Scalar_Type (E)
- then
- Error_Msg_N
- ("aspect% can only be applied to scalar type", Id);
- goto Continue;
+ elsif A_Id = Aspect_Default_Value then
+ if not Is_Scalar_Type (E) then
+ Error_Msg_N
+ ("aspect% can only be applied to scalar type", Id);
+ goto Continue;
+ end if;
elsif A_Id = Aspect_Default_Component_Value then
if not Is_Array_Type (E) then
@@ -11118,7 +11118,7 @@ package body Sem_Ch13 is
-- If the end of declarations comes before any other freeze point,
-- the Freeze_Expr is not analyzed: no check needed.
- if Analyzed (Freeze_Expr) and then not In_Instance then
+ if Analyzed (Freeze_Expr) then
Check_Overloaded_Name;
else
Err := False;