From ef191225d89cce2b1c60a4ba3f25f12be65810f3 Mon Sep 17 00:00:00 2001 From: Romain Beguet Date: Thu, 15 Feb 2024 15:45:08 +0100 Subject: [PATCH] Fix GNAT FSF build by making P_Call_Context private. --- ada/ast.py | 4 ++-- .../src/libadalang-semantic_diagnostics.adb | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ada/ast.py b/ada/ast.py index 7edb17315..a41ae68bf 100644 --- a/ada/ast.py +++ b/ada/ast.py @@ -477,8 +477,8 @@ def valid_keywords(): "when", "while", "with", "xor" ]) - @langkit_property(public=True, return_type=T.AdaNode, - ignore_warn_on_node=True) + @langkit_property(return_type=T.AdaNode, ignore_warn_on_node=True, + warn_on_unused=False) def call_context(ctx=T.LogicContext): """ Assuming that Self is the error location of a semantic diagnostic and diff --git a/extensions/src/libadalang-semantic_diagnostics.adb b/extensions/src/libadalang-semantic_diagnostics.adb index 7ac1aa5e0..7755ed840 100644 --- a/extensions/src/libadalang-semantic_diagnostics.adb +++ b/extensions/src/libadalang-semantic_diagnostics.adb @@ -8,6 +8,8 @@ with Ada.Strings.Wide_Wide_Unbounded; use Ada.Strings.Wide_Wide_Unbounded; with Langkit_Support.Slocs; use Langkit_Support.Slocs; with Libadalang.Common; use Libadalang.Common; +with Libadalang.Implementation; +with Libadalang.Public_Converters; package body Libadalang.Semantic_Diagnostics is @@ -186,13 +188,25 @@ package body Libadalang.Semantic_Diagnostics is for Diag of Kept loop declare - Ctxs : constant Logic_Context_Array := Contexts (Diag); + use Libadalang.Implementation; + use Libadalang.Public_Converters; + + Ctxs : constant Logic_Context_Array := Contexts (Diag); + Last_Ctx : constant Logic_Context := Ctxs (Ctxs'Last); + Internal_Ctx : constant Internal_Logic_Context := + (Unwrap_Entity (Ref_Node (Last_Ctx)), + Unwrap_Entity (Decl_Node (Last_Ctx))); + + Base_Loc : constant Ada_Node'Class := Location (Diag); + Contextual_Loc : constant Ada_Node := Wrap_Node + (Ada_Node_P_Call_Context + (Unwrap_Node (Base_Loc), + Internal_Ctx)); begin Res.Contexts.Append (Render_Diagnostic (Diag, Render_Node, - Location (Diag).P_Call_Context - (Ctxs (Ctxs'Last)))); + Contextual_Loc)); end; exit when Res.Contexts.Length >= Max_Alt_Count; end loop;