[COMMITTED,25/51] ada: Avoid referencing ignored ghost nodes in finalizer

Message ID 20260602084541.3829876-25-poulhies@adacore.com
State Committed
Commit d9d35f1cb6de2053337af3b5c39747f5ef066eae
Headers
Series [COMMITTED,01/51] ada: Rename Private_Component function |

Commit Message

Marc Poulhiès June 2, 2026, 8:45 a.m. UTC
  From: Viljar Indus <indus@adacore.com>

gcc/ada/ChangeLog:

	* exp_ch7.adb (Processing_Actions): Avoid processing
	ignored ghost declarations.

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

---
 gcc/ada/exp_ch7.adb | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Patch

diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 292327c67c5..f4f30dcc85d 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -2430,6 +2430,14 @@  package body Exp_Ch7 is
             Strict       : Boolean := False)
          is
          begin
+            --  No need to process ignored ghost declarations as they will be
+            --  removed later and therefore do not need finalization
+            --  primitives.
+
+            if Is_Ignored_Ghost_Node (Decl) then
+               return;
+            end if;
+
             --  Library-level tagged type
 
             if Nkind (Decl) = N_Full_Type_Declaration then