end Proper_Op;
begin
- Resolve (Init_Value_Exp, Typ);
+ -- First try to resolve the reducer and then, if this succeeds,
+ -- resolve the initial value. This nicely deals with confused
+ -- programmers who swap the two items.
+
if Is_Overloaded (Reducer_Subp_Name) then
Outer :
for Retry in Boolean loop
then
Op := Reducer_Subp_Name;
- elsif Proper_Op (Entity (Reducer_Subp_Name)) then
+ elsif Is_Entity_Name (Reducer_Subp_Name)
+ and then Proper_Op (Entity (Reducer_Subp_Name))
+ then
Op := Entity (Reducer_Subp_Name);
Set_Etype (N, Typ);
end if;
if No (Op) then
- Error_Msg_N ("No suitable reducer subprogram found",
+ Error_Msg_N ("no suitable reducer subprogram found",
Reducer_Subp_Name);
+ else
+ Resolve (Init_Value_Exp, Typ);
end if;
end;
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-gnat2022" }
+
+procedure Reduce1 is
+
+ type Arr is array (Positive range <>) of Positive;
+
+ A: Arr := (2, 87);
+
+ B: Positive := A'Reduce (1, Positive'Max); -- { dg-error "no suitable" }
+
+begin
+ null;
+end;