https://gcc.gnu.org/g:a5e6571ead09734d89346d23b7f39cd5486959c6

commit r17-1182-ga5e6571ead09734d89346d23b7f39cd5486959c6
Author: Viljar Indus <[email protected]>
Date:   Wed Apr 8 13:02:06 2026 +0300

    ada: Improve error message for incorrect call arguments
    
    Enumeration literals are considered as zero argument functions.
    This is not obvious for most users and can create confusing error
    messages when an enumeration literal is referred to as a call. For
    example if there are indices applied to it.
    
    Instead create a dedicated error message for this scenario.
    
    gcc/ada/ChangeLog:
    
            * sem_util.adb (Normalize_Actuals): Improve error message.

Diff:
---
 gcc/ada/sem_util.adb | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 89060c31acd0..1745accfe598 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -25981,7 +25981,19 @@ package body Sem_Util is
 
          if Reporting then
             if Is_Entity_Name (Name (N)) then
-               Error_Msg_N ("too many arguments in call to&", Name (N));
+               if Ekind (S) = E_Enumeration_Literal then
+                  Error_Msg_N ("cannot index enumeration literal &", Name (N));
+                  if Present (Homonym (S))
+                    and then Sloc (Homonym (S)) = Standard_Location
+                  then
+                     Error_Msg_NE
+                       ("\\did you mean & in Standard'?",
+                        Name (N),
+                        Homonym (S));
+                  end if;
+               else
+                  Error_Msg_N ("too many arguments in call to&", Name (N));
+               end if;
             else
                Error_Msg_N ("too many arguments in call", N);
             end if;

Reply via email to