[Ada] Freeze target type on qualified expression expansion

Message ID 20220516084318.GA3843784@adacore.com
State Committed
Commit 26bbf0e5da9af096eeddc2a79e1e0da9673b6bd2
Headers
Series [Ada] Freeze target type on qualified expression expansion |

Commit Message

Pierre-Marie de Rodat May 16, 2022, 8:43 a.m. UTC
  An object declaration (other than a deferred constant declaration)
causes freezing where it occurs (13.14(6)), which means every name
occurring within it causes freezing (13.14(4/1)), and when the name in a
subtype_mark causes freezing, the denoted subtype is frozen (13.14(11)).
Hence, one needs to freeze the target type when expanding a qualified
expression.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* exp_ch4.adb (Expand_N_Qualified_Expression): Freeze
	Target_Type.
  

Patch

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -10776,6 +10776,8 @@  package body Exp_Ch4 is
          Ensure_Valid (Operand);
       end if;
 
+      Freeze_Before (Operand, Target_Type);
+
       --  Apply possible constraint check
 
       Apply_Constraint_Check (Operand, Target_Type, No_Sliding => True);