Resolve_Qualified_Expression propagates the type of the operand into
the node itself if the original type of the node is unconstrained,
but this is not needed for an allocator and might be problematic,
e.g. for the CCG compiler which expects unconstrained array types.
No functional changes.
Tested on x86_64-pc-linux-gnu, committed on trunk
2020-06-19 Eric Botcazou <ebotca...@adacore.com>
gcc/ada/
* sem_res.adb (Resolve_Qualified_Expression): Do not override the
type of the node when it is unconstrained if it is for an allocator.
--- gcc/ada/sem_res.adb
+++ gcc/ada/sem_res.adb
@@ -10161,10 +10161,12 @@ package body Sem_Res is
-- If the target type is unconstrained, then we reset the type of the
-- result from the type of the expression. For other cases, the actual
- -- subtype of the expression is the target type.
+ -- subtype of the expression is the target type. But we avoid doing it
+ -- for an allocator since this is not needed and might be problematic.
if Is_Composite_Type (Target_Typ)
and then not Is_Constrained (Target_Typ)
+ and then Nkind (Parent (N)) /= N_Allocator
then
Set_Etype (N, Etype (Expr));
end if;