diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-04-25 14:49:24 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-04-25 14:49:24 +0200 |
commit | cccb761bc29d4c32a24c79d68ef9ac76308d54fc (patch) | |
tree | 073ce133334332707c1a88c967b562f9cbf9bbd8 /gcc/ada/sem_res.adb | |
parent | 6a3936d48b36c09a5f7654ae2bc3a62d688bd414 (diff) | |
download | gcc-cccb761bc29d4c32a24c79d68ef9ac76308d54fc.zip gcc-cccb761bc29d4c32a24c79d68ef9ac76308d54fc.tar.gz gcc-cccb761bc29d4c32a24c79d68ef9ac76308d54fc.tar.bz2 |
[multiple changes]
2017-04-25 Pascal Obry <obry@adacore.com>
* g-sercom.ads: Add simple usage of GNAT.Serial_Communication.
2017-04-25 Hristian Kirtchev <kirtchev@adacore.com>
* sem_res.adb (Resolve_Type_Conversion):
When resolving against any fixed type, set the type of the
operand as universal real when the operand is a multiplication
or a division where both operands are of any fixed type.
(Unique_Fixed_Point_Type): Add local variable ErrN. Improve the
placement of an error message by pointing to the operand of a
type conversion rather than the conversion itself.
2017-04-25 Thomas Quinot <quinot@adacore.com>
* sem_ch13.adb (Build_Predicate_Function_Declaration): Set
Needs_Debug_Info when producing SCOs.
2017-04-25 Thomas Quinot <quinot@adacore.com>
* exp_ch6.adb (Add_Finalization_Master_Actual_To_Build_In_Place_Call):
Always pass a null finalization master for a library level named access
type to which a pragme No_Heap_Finalization applies.
From-SVN: r247216
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r-- | gcc/ada/sem_res.adb | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 683686f..2a8010d 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -10711,7 +10711,15 @@ package body Sem_Res is -- Mixed-mode operation involving a literal. Context must be a fixed -- type which is applied to the literal subsequently. - if Is_Fixed_Point_Type (Typ) then + -- Multiplication and division involving two fixed type operands must + -- yield a universal real because the result is computed in arbitrary + -- precision. + + if Is_Fixed_Point_Type (Typ) + and then Nkind_In (Operand, N_Op_Divide, N_Op_Multiply) + and then Etype (Left_Opnd (Operand)) = Any_Fixed + and then Etype (Right_Opnd (Operand)) = Any_Fixed + then Set_Etype (Operand, Universal_Real); elsif Is_Numeric_Type (Typ) @@ -11722,12 +11730,7 @@ package body Sem_Res is ----------------------------- function Unique_Fixed_Point_Type (N : Node_Id) return Entity_Id is - T1 : Entity_Id := Empty; - T2 : Entity_Id; - Item : Node_Id; - Scop : Entity_Id; - - procedure Fixed_Point_Error; + procedure Fixed_Point_Error (T1 : Entity_Id; T2 : Entity_Id); -- Give error messages for true ambiguity. Messages are posted on node -- N, and entities T1, T2 are the possible interpretations. @@ -11735,13 +11738,21 @@ package body Sem_Res is -- Fixed_Point_Error -- ----------------------- - procedure Fixed_Point_Error is + procedure Fixed_Point_Error (T1 : Entity_Id; T2 : Entity_Id) is begin Error_Msg_N ("ambiguous universal_fixed_expression", N); Error_Msg_NE ("\\possible interpretation as}", N, T1); Error_Msg_NE ("\\possible interpretation as}", N, T2); end Fixed_Point_Error; + -- Local variables + + ErrN : Node_Id; + Item : Node_Id; + Scop : Entity_Id; + T1 : Entity_Id; + T2 : Entity_Id; + -- Start of processing for Unique_Fixed_Point_Type begin @@ -11761,7 +11772,7 @@ package body Sem_Res is and then Scope (Base_Type (T2)) = Scop then if Present (T1) then - Fixed_Point_Error; + Fixed_Point_Error (T1, T2); return Any_Type; else T1 := T2; @@ -11787,7 +11798,7 @@ package body Sem_Res is and then (Is_Potentially_Use_Visible (T2) or else In_Use (T2)) then if Present (T1) then - Fixed_Point_Error; + Fixed_Point_Error (T1, T2); return Any_Type; else T1 := T2; @@ -11802,11 +11813,20 @@ package body Sem_Res is end loop; if Nkind (N) = N_Real_Literal then - Error_Msg_NE - ("??real literal interpreted as }!", N, T1); + Error_Msg_NE ("??real literal interpreted as }!", N, T1); + else + -- When the context is a type conversion, issue the warning on the + -- expression of the conversion because it is the actual operation. + + if Nkind_In (N, N_Type_Conversion, N_Unchecked_Type_Conversion) then + ErrN := Expression (N); + else + ErrN := N; + end if; + Error_Msg_NE - ("??universal_fixed expression interpreted as }!", N, T1); + ("??universal_fixed expression interpreted as }!", ErrN, T1); end if; return T1; |