]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix assertion failure on predicate involving access parameter
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 21 May 2024 17:49:32 +0000 (19:49 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 21 Jun 2024 08:34:18 +0000 (10:34 +0200)
The assertion fails because the Original_Node of the expression has no Etype
since its an unanalyzed identifier.

gcc/ada/

* accessibility.adb (Accessibility_Level): Apply the processing to
Expr when its Original_Node is an unanalyzed identifier.

gcc/ada/accessibility.adb

index da4d1d9ce2e2c48077763bc980138afc7d0e071d..298103377a7bcc9f15ce0dc2bc49b87b4253a256 100644 (file)
@@ -398,7 +398,7 @@ package body Accessibility is
 
       --  Local variables
 
-      E   : Node_Id := Original_Node (Expr);
+      E   : Node_Id;
       Pre : Node_Id;
 
    --  Start of processing for Accessibility_Level
@@ -409,6 +409,17 @@ package body Accessibility is
 
       if Present (Param_Entity (Expr)) then
          E := Param_Entity (Expr);
+
+      --  Use the original node unless it is an unanalyzed identifier, as we
+      --  don't want to reason on unanalyzed expressions from predicates.
+
+      elsif Nkind (Original_Node (Expr)) /= N_Identifier
+        or else Analyzed (Original_Node (Expr))
+      then
+         E := Original_Node (Expr);
+
+      else
+         E := Expr;
       end if;
 
       --  Extract the entity