From: Viljar Indus <[email protected]>

This method would crash if the association was not a
N_Component_Association. As it could be something else like an
N_Iterated_Component_Association that does not have the choices
attribute.

gcc/ada/ChangeLog:

        * sem_util.adb (Has_Assertion_Level_Argument): Check for
        the correct type of association.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_util.adb | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 5698b2f0fef..43850d6cfc2 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -11510,6 +11510,11 @@ package body Sem_Util is
          end if;
 
          Assoc := First (Assocs);
+
+         if Nkind (Assoc) /= N_Component_Association then
+            return False;
+         end if;
+
          Choice := First (Choices (Assoc));
 
          if Nkind (Choice) = N_Identifier then
-- 
2.53.0

Reply via email to