public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Ignore accessibility actuals in expression pretty-printer
@ 2023-05-23  8:07 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-05-23  8:07 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

From: Piotr Trojanek <trojanek@adacore.com>

Extra actual parameters for accessibility checks are confusing for the
expression pretty-printer that is used by CodePeer. It seems that nodes
created for the accessibility checks should use the Sloc of the source
expression of accessibility checks, not the target. However, this is
problematic to achieve with the current implementation of accessibility
checks, so with this patch we will simply ignore the accessibility
actuals when computing Slocs for expression pretty-printing.

gcc/ada/

	* errout.adb (First_And_Last_Nodes): Ignore accessibility parameters.

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

---
 gcc/ada/errout.adb | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 0a36a1d7466..5c3e76c5eca 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -1769,6 +1769,24 @@ package body Errout is
          Loc   : constant Source_Ptr := Sloc (Norig);
 
       begin
+         --  ??? For assignments that require accessiblity checks, e.g.:
+         --
+         --    Y := Func (123);
+         --
+         --  the function call gets an extra actual parameter association with
+         --  Sloc of the assigned name "Y":
+         --
+         --    Y := Func (123, A8b => 2);
+         --
+         --  We can simply ignore those extra actual parameters when
+         --  determining the Sloc range of the "Func (123)" expression.
+
+         if Nkind (N) = N_Parameter_Association
+           and then Is_Accessibility_Actual (N)
+         then
+            return Skip;
+         end if;
+
          --  Check for earlier
 
          if Loc < Eloc
-- 
2.40.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-23  8:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23  8:07 [COMMITTED] ada: Ignore accessibility actuals in expression pretty-printer Marc Poulhiès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).