https://gcc.gnu.org/g:73096437b4cf320d70c705a055973f74609126a2

commit r17-878-g73096437b4cf320d70c705a055973f74609126a2
Author: Marc Poulhiès <[email protected]>
Date:   Tue Mar 3 11:45:20 2026 +0100

    ada: vast: protect against a predicate failure
    
    In case where the node is not a Pragma as expected, don't try to check
    its field as it can raise a predicate error.
    
    gcc/ada/ChangeLog:
    
            * vast.adb (Do_Node_Pass_2): Only check aspect/pragma consistency 
for pragma nodes.

Diff:
---
 gcc/ada/vast.adb | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/vast.adb b/gcc/ada/vast.adb
index 4a26ddb5b846..d511532a3fc0 100644
--- a/gcc/ada/vast.adb
+++ b/gcc/ada/vast.adb
@@ -636,10 +636,16 @@ package body VAST is
          if Present (Aspect_Rep_Item (N)) then
             Assert (Nkind (Aspect_Rep_Item (N)) = N_Pragma,
                     Check_Corresponding_Aspect);
-            Assert (From_Aspect_Specification (Aspect_Rep_Item (N)),
-                    Check_Corresponding_Aspect);
-            Assert (Corresponding_Aspect (Aspect_Rep_Item (N)) = N,
-                    Check_Corresponding_Aspect);
+
+            --  If the above check fails, the test below may raise predicate
+            --  failures, no need to check for pragma/aspect consistency for
+            --  other nodes.
+            if Nkind (Aspect_Rep_Item (N)) = N_Pragma then
+               Assert (From_Aspect_Specification (Aspect_Rep_Item (N)),
+                       Check_Corresponding_Aspect);
+               Assert (Corresponding_Aspect (Aspect_Rep_Item (N)) = N,
+                       Check_Corresponding_Aspect);
+            end if;
          end if;
       end if;

Reply via email to