From: Viljar Indus <[email protected]>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
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 89060c31acd..1745accfe59 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;
--
2.53.0