diff options
author | Yannick Moy <moy@adacore.com> | 2019-07-01 13:35:38 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-01 13:35:38 +0000 |
commit | 1d0b1439ae4db4b52cb2bfd6b786d68bb8b5bb15 (patch) | |
tree | 8564f4a30bd851f6021a87f58e68814c03266dfb /gcc/ada/sem_ch4.adb | |
parent | 25feb37fc665e0c46ee2deec9f47f5ffd4cdd702 (diff) | |
download | gcc-1d0b1439ae4db4b52cb2bfd6b786d68bb8b5bb15.zip gcc-1d0b1439ae4db4b52cb2bfd6b786d68bb8b5bb15.tar.gz gcc-1d0b1439ae4db4b52cb2bfd6b786d68bb8b5bb15.tar.bz2 |
[Ada] Improve error message on mult/div between fixed-point and integer
Multiplication and division of a fixed-point type by an integer type is
only defined by default for type Integer. Clarify the error message to
explain that a conversion is needed in other cases.
Also change an error message to start with lowercase as it should be.
2019-07-01 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_ch4.adb (Operator_Check): Refine error message.
From-SVN: r272866
Diffstat (limited to 'gcc/ada/sem_ch4.adb')
-rw-r--r-- | gcc/ada/sem_ch4.adb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 2c40011..03a156a 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -7375,7 +7375,7 @@ package body Sem_Ch4 is Etype (Next_Formal (First_Formal (Op_Id)))) then Error_Msg_N - ("No legal interpretation for operator&", N); + ("no legal interpretation for operator&", N); Error_Msg_NE ("\use clause on& would make operation legal", N, Scope (Op_Id)); @@ -7393,6 +7393,26 @@ package body Sem_Ch4 is Error_Msg_NE ("\left operand has}!", N, Etype (L)); Error_Msg_NE ("\right operand has}!", N, Etype (R)); + -- For multiplication and division operators with + -- a fixed-point operand and an integer operand, + -- indicate that the integer operand should be of + -- type Integer. + + if Nkind_In (N, N_Op_Multiply, N_Op_Divide) + and then Is_Fixed_Point_Type (Etype (L)) + and then Is_Integer_Type (Etype (R)) + then + Error_Msg_N ("\convert right operand to " + & "`Integer`", N); + + elsif Nkind (N) = N_Op_Multiply + and then Is_Fixed_Point_Type (Etype (R)) + and then Is_Integer_Type (Etype (L)) + then + Error_Msg_N ("\convert left operand to " + & "`Integer`", N); + end if; + -- For concatenation operators it is more difficult to -- determine which is the wrong operand. It is worth -- flagging explicitly an access type, for those who |