]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix detection of non-static expressions in records with pragmas
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 23 Mar 2023 17:46:08 +0000 (18:46 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 26 May 2023 07:29:18 +0000 (09:29 +0200)
When iterating over record components we must ignore pragmas.
Minor bug, as pragmas within record components do not appear often.

gcc/ada/

* sem_cat.adb (Check_Non_Static_Default_Expr): Detect components inside
loop, not in the loop condition itself.

gcc/ada/sem_cat.adb

index 09560e6179ace7b6efa111ca99f5d29d30cee762..13dff3dbdd93989193a42e0104ca4a1a248a81c8 100644 (file)
@@ -346,14 +346,13 @@ package body Sem_Cat is
 
       if Null_Present (Recdef) then
          return;
-      else
-         Component_Decl := First (Component_Items (Component_List (Recdef)));
       end if;
 
-      while Present (Component_Decl)
-        and then Nkind (Component_Decl) = N_Component_Declaration
-      loop
-         if Present (Expression (Component_Decl))
+      Component_Decl := First (Component_Items (Component_List (Recdef)));
+
+      while Present (Component_Decl) loop
+         if Nkind (Component_Decl) = N_Component_Declaration
+           and then Present (Expression (Component_Decl))
            and then Nkind (Expression (Component_Decl)) /= N_Null
            and then not Is_OK_Static_Expression (Expression (Component_Decl))