https://gcc.gnu.org/g:29447fb66f7cf4a515cbbcc812008092d519bc9c

commit r15-9767-g29447fb66f7cf4a515cbbcc812008092d519bc9c
Author: Steve Baird <ba...@adacore.com>
Date:   Fri Jan 10 13:15:18 2025 -0800

    ada: Avoid calling Resolve with Stand.Any_Fixed as the expected type
    
    When we call Resolve for an expression, we pass in the expected type
    for that expression. In the absence of semantic errors, that expected type
    should never be any of the "Any_xxx" types declared in stand.ads (e.g.,
    Any_Array, Any_Numeric, Any_Real). In particular, it should never be 
Any_Fixed.
    Fix a case in which this rule was being violated.
    
    gcc/ada/ChangeLog:
    
            * sem_res.adb
            (Set_Mixed_Mode_Operand): If we are about to call Resolve
            passing in Any_Fixed as the expected type, then instead pass in
            the fixed point type of the other operand (i.e., B_Typ).

Diff:
---
 gcc/ada/sem_res.adb | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index b73b947c9a25..0df6c27c30d7 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -6101,6 +6101,8 @@ package body Sem_Res is
                elsif Is_Fixed_Point_Type (It.Typ) then
                   if Analyzed (N) then
                      Error_Msg_N ("ambiguous operand in fixed operation", N);
+                  elsif It.Typ = Any_Fixed then
+                     Resolve (N, B_Typ);
                   else
                      Resolve (N, It.Typ);
                   end if;

Reply via email to