diff mbox series

[COMMITTED] ada: Fix detection of non-static expressions in records with pragmas

Message ID 20230526073629.2069189-1-poulhies@adacore.com
State New
Headers show
Series [COMMITTED] ada: Fix detection of non-static expressions in records with pragmas | expand

Commit Message

Marc Poulhiès May 26, 2023, 7:36 a.m. UTC
From: Piotr Trojanek <trojanek@adacore.com>

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.

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

---
 gcc/ada/sem_cat.adb | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/sem_cat.adb b/gcc/ada/sem_cat.adb
index 09560e6179a..13dff3dbdd9 100644
--- a/gcc/ada/sem_cat.adb
+++ b/gcc/ada/sem_cat.adb
@@ -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))