diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2024-01-31 15:32:22 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-13 10:03:33 +0200 |
commit | c1ece0ca7d31f191c97ff0bdc72e0f0416e72774 (patch) | |
tree | fe131d002887eb621e930dd226533e75d84175f7 /gcc/ada/sem_disp.adb | |
parent | b3eef3b124d1eee9cd261fb072d6e1667cd2501a (diff) | |
download | gcc-c1ece0ca7d31f191c97ff0bdc72e0f0416e72774.zip gcc-c1ece0ca7d31f191c97ff0bdc72e0f0416e72774.tar.gz gcc-c1ece0ca7d31f191c97ff0bdc72e0f0416e72774.tar.bz2 |
ada: Remove guards against traversal of empty list of aspects
When iterating over Aspect_Specifications, we can use First/Next
directly even if the Aspect_Specifications returns a No_List or
the list has no items.
Code cleanup.
gcc/ada/
* aspects.adb (Copy_Aspects): Style fix.
* contracts.adb (Analyze_Contracts): Style fix.
(Save_Global_References_In_Contract): Remove extra guards.
* par_sco.adb (Traverse_Aspects): Move guard to the caller and
make it consistent with Save_Global_References_In_Contract.
* sem_ch12.adb (Has_Contracts): Remove extra guards.
* sem_ch3.adb (Delayed_Aspect_Present, Get_Partial_View_Aspect,
Check_Duplicate_Aspects): Likewise.
* sem_disp.adb (Check_Dispatching_Operation): Likewise.
Diffstat (limited to 'gcc/ada/sem_disp.adb')
-rw-r--r-- | gcc/ada/sem_disp.adb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/gcc/ada/sem_disp.adb b/gcc/ada/sem_disp.adb index e1b35a6..525a9f7 100644 --- a/gcc/ada/sem_disp.adb +++ b/gcc/ada/sem_disp.adb @@ -1932,19 +1932,17 @@ package body Sem_Disp is Asp : Node_Id; begin - if Present (Aspect_Specifications (W_Decl)) then - Asp := First (Aspect_Specifications (W_Decl)); - while Present (Asp) loop - if Chars (Identifier (Asp)) = Name_Yield then - Error_Msg_Name_1 := Name_Yield; - Error_Msg_N - ("specification of inherited aspect% can only confirm " - & "parent value", Asp); - end if; + Asp := First (Aspect_Specifications (W_Decl)); + while Present (Asp) loop + if Chars (Identifier (Asp)) = Name_Yield then + Error_Msg_Name_1 := Name_Yield; + Error_Msg_N + ("specification of inherited aspect% can only confirm " + & "parent value", Asp); + end if; - Next (Asp); - end loop; - end if; + Next (Asp); + end loop; Set_Has_Yield_Aspect (Wrapped_Entity (Subp)); end; |