From: Javier Miranda <[email protected]>
Avoid reporting spurious errors.
gcc/ada/ChangeLog:
* freeze.adb (Freeze_Expr_Types): Reverse patch; that is, restore
calls to Preanalyze_Spec_Expression instead of Preanalyze_And_Resolve
for the sake of consistency with Analyze_Expression_Function. Patch
suggested by Eric Botcazou.
* exp_put_image.adb (Image_Should_Call_Put_Image): Ensure that
function Defining_Identifier is called with a proper node to
avoid internal assertion failure.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/exp_put_image.adb | 2 ++
gcc/ada/freeze.adb | 8 +++++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/gcc/ada/exp_put_image.adb b/gcc/ada/exp_put_image.adb
index 38bde44ff5a..ae5fa40fa38 100644
--- a/gcc/ada/exp_put_image.adb
+++ b/gcc/ada/exp_put_image.adb
@@ -1190,6 +1190,8 @@ package body Exp_Put_Image is
-- aspects, not just for Put_Image?
if Is_Itype (U_Type)
+ and then Nkind (Associated_Node_For_Itype (U_Type)) in
+ N_Full_Type_Declaration | N_Subtype_Declaration
and then Has_Aspect (Defining_Identifier
(Associated_Node_For_Itype (U_Type)),
Aspect_Put_Image)
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 10f0de78d9d..54b620214e8 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -9389,14 +9389,16 @@ package body Freeze is
-- pre/postconditions during expansion of the subprogram body, the
-- subprogram is already installed.
+ -- Call Preanalyze_Spec_Expression instead of Preanalyze_And_Resolve
+ -- for the sake of consistency with Analyze_Expression_Function.
+
if Def_Id /= Current_Scope then
Push_Scope (Def_Id);
Install_Formals (Def_Id);
-
- Preanalyze_And_Resolve (Dup_Expr, Typ);
+ Preanalyze_Spec_Expression (Dup_Expr, Typ);
End_Scope;
else
- Preanalyze_And_Resolve (Dup_Expr, Typ);
+ Preanalyze_Spec_Expression (Dup_Expr, Typ);
end if;
-- Restore certain attributes of Def_Id since the preanalysis may
--
2.43.0