aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog14
-rw-r--r--gcc/ada/rtfinal.c2
-rw-r--r--gcc/ada/rtinit.c3
-rw-r--r--gcc/ada/sem_attr.adb47
4 files changed, 42 insertions, 24 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index fca1a9e..8b19deb 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,17 @@
+2025-12-08 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR ada/123037
+ * rtinit.c [__MINGW32__]: Include <stdlib.h> and not <windows.h>.
+ * rtfinal.c [__MINGW32__]: Do not include <windows.h>.
+
+2025-12-07 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR ada/115349
+ * sem_attr.adb (Resolve_Attribute) <Attribute_Reduce>: Use the base
+ type as Accum_Type if the reducer is an operator from Standard and
+ the type is numeric. Use the type of the first operand for other
+ operators. Streamline the error message given for limited types.
+
2025-12-06 Denis Mazzucato <mazzucato@adacore.com>
* sem_attr.adb (Resolve_Attribute): Check if the reducer is a
diff --git a/gcc/ada/rtfinal.c b/gcc/ada/rtfinal.c
index 88bbb0e..0bd3ce4 100644
--- a/gcc/ada/rtfinal.c
+++ b/gcc/ada/rtfinal.c
@@ -46,9 +46,7 @@ extern int __gnat_rt_init_count;
/* see initialize.c */
#if defined (__MINGW32__)
-#define WIN32_LEAN_AND_MEAN
#include "mingw32.h"
-#include <windows.h>
extern CRITICAL_SECTION ProcListCS;
extern HANDLE ProcListEvt;
diff --git a/gcc/ada/rtinit.c b/gcc/ada/rtinit.c
index 598550c..3b5af0d 100644
--- a/gcc/ada/rtinit.c
+++ b/gcc/ada/rtinit.c
@@ -70,9 +70,8 @@ int __gnat_rt_init_count = 0;
and finalize properly the run-time. */
#if defined (__MINGW32__)
-#define WIN32_LEAN_AND_MEAN
+#include <stdlib.h>
#include "mingw32.h"
-#include <windows.h>
extern void __gnat_init_float (void);
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index ca19cad..74e9d6f 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -12919,7 +12919,7 @@ package body Sem_Attr is
-- Where the context is augmented with the iteration
-- variable I of the right type, and Init_Var of type
- -- Accum_Subtype. If the Reducer has both procedure and
+ -- Accum_Typ. If the Reducer has both procedure and
-- function interpretations with the proper reducer profile
-- an ambiguity error is emitted. Note that, this could be a
-- false positive as the two may coexist without ambiguity
@@ -13204,7 +13204,7 @@ package body Sem_Attr is
return;
end if;
- -- If no error has been posted and the accumulation type is
+ -- If no error has been posted and the accumulator type is
-- constrained, then the resolution of the reducer can start.
if Nkind (Reducer_N) = N_Attribute_Reference then
@@ -13252,44 +13252,50 @@ package body Sem_Attr is
end if;
end if;
- -- After resolving the reducer, determine the correct
- -- Accum_Subtype: if the reducer is an attribute (Min or Max),
- -- then the prefix type is the accumulation type.
+ -- After resolving the reducer, determine Accum_Typ: if the
+ -- reducer is an attribute (Min or Max), then its prefix is
+ -- the accumulator type.
if Nkind (Reducer_E) = N_Attribute_Reference then
- Accum_Typ := Etype (Prefix (Reducer_E));
+ Accum_Typ := Entity (Prefix (Reducer_E));
- -- If an operator from standard, then the type of its first
- -- formal woudl be Any_Type, in this case we make sure we don't
- -- use an universal type to avoid resolution problems later on.
+ -- If the reducer is an operator from Standard, then the type
+ -- of its first operand would be Any_Type. In this case, make
+ -- sure we do not have an universal type to avoid resolution
+ -- problems later on, and use the base type of numeric types
+ -- to avoid spurious subtype mismatches for the initial value.
- elsif Ekind (Reducer_E) = E_Operator
- or else Scope (Reducer_E) = Standard_Standard
- then
+ elsif Scope (Reducer_E) = Standard_Standard then
if Accum_Typ = Universal_Integer then
Accum_Typ := Standard_Integer;
elsif Accum_Typ = Universal_Real then
Accum_Typ := Standard_Float;
+ elsif Is_Numeric_Type (Accum_Typ) then
+ Accum_Typ := Base_Type (Accum_Typ);
end if;
- -- Otherwise, the Accum_Subtype is the subtype of the first
- -- formal of the reducer subprogram RM 4.5.10(19/5).
+ -- Otherwise, Accum_Typ is the subtype of the first formal
+ -- of the reducer subprogram (RM 4.5.10(19/5)).
+
+ elsif Ekind (Reducer_E) = E_Operator then
+ Accum_Typ := Etype (Left_Opnd (Reducer_E));
else
Accum_Typ := Etype (First_Formal (Reducer_E));
end if;
+
Set_Etype (N, Accum_Typ);
- -- Accumulation type must be nonlimited, RM 4.5.10(8/5)
+ -- The accumulator type must be nonlimited (RM 4.5.10(8/5))
if Is_Limited_Type (Accum_Typ) then
Error_Msg_N
- ("accumulated subtype of Reduce must be nonlimited", N);
+ ("type of reduction expression must be nonlimited", N);
- -- If the Accum_Typ is an unconstrained array and the reducer
+ -- If Accum_Typ is an unconstrained array and the reducer
-- subprogram is a function then a Constraint_Error will be
- -- raised at runtime as most computations will change its
- -- length type during the reduction execution, RM 4.5.10(25/5).
+ -- raised at run time, as most computations will change its
+ -- length during the reduction execution (RM 4.5.10(25/5)).
-- For instance, this is the case with:
-- [...]'Reduce ("&", ...)
-- When the expression yields non-empty strings, the reduction
@@ -13300,7 +13306,7 @@ package body Sem_Attr is
elsif Nkind (Reducer_E) /= N_Attribute_Reference
and then Ekind (Reducer_E) = E_Function
- and then not Is_Numeric_Type (Base_Type (Accum_Typ))
+ and then not Is_Numeric_Type (Accum_Typ)
and then not Is_Constrained (Accum_Typ)
then
declare
@@ -13318,6 +13324,7 @@ package body Sem_Attr is
-- resolving the initial expression and array aggregate.
Resolve (Init_Value_Expr, Accum_Typ);
+
if Nkind (P) = N_Aggregate then
Resolve_Aggregate (P,
Make_Array_Type (Index => Standard_Positive,