public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Error message on invalid prefixed procedure call
@ 2021-05-03  9:29 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-03  9:29 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ed Schonberg

[-- Attachment #1: Type: text/plain, Size: 780 bytes --]

When the prefix of a call denotes an overloaded primitive operation, all
possible interpretations are analyzed to determine the intended one. If
all of them fail, then if the All_Errors flag is on all interpretations
are analyzed anew to indicate why each one is illegal. If All_Errors is
not set then only one interpretation is reanalyzed, which in rare cases
will fail to provide a meaningful error message. This patch adds the
required message and prevents the construction of an invalid tree.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_ch4.adb (Try_Object_Operation): When a prefixed call is
	overloaded and illegal, and the All_Errors flag is off, generate
	an error message if the re-analysis of some candidate
	interpretation fails to produce one.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 764 bytes --]

diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -10215,6 +10215,16 @@ package body Sem_Ch4 is
                Report     => True,
                Success    => Success,
                Skip_First => True);
+
+            --  The error may hot have been reported yet for overloaded
+            --  prefixed calls, depending on the non-matching candidate,
+            --  in which case provide a concise error now.
+
+            if Serious_Errors_Detected = 0 then
+               Error_Msg_NE
+                 ("cannot resolve prefixed call to primitive operation of&",
+                   N, Entity (Prefix (N)));
+            end if;
          end if;
 
          --  No need for further errors



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

only message in thread, other threads:[~2021-05-03  9:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03  9:29 [Ada] Error message on invalid prefixed procedure call Pierre-Marie de Rodat

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).