diff options
author | Yannick Moy <moy@adacore.com> | 2024-05-23 14:39:19 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-06-20 10:50:56 +0200 |
commit | 3c6dcd1d018da645316e3969748d70a1efd66dd2 (patch) | |
tree | d2fcea15ee2f0ea490af13eca8c62556e14832de /gcc/ada/tbuild.adb | |
parent | c5d7daa37938984b931ae0825e9d3d72c748ab5a (diff) | |
download | gcc-3c6dcd1d018da645316e3969748d70a1efd66dd2.zip gcc-3c6dcd1d018da645316e3969748d70a1efd66dd2.tar.gz gcc-3c6dcd1d018da645316e3969748d70a1efd66dd2.tar.bz2 |
ada: Fix inlining of fixed-lower-bound array for GNATprove
Inlining in GNATprove may fail on a call to a subprogram with a formal
of an array type with fixed lower bound (a GNAT extension), because the
appropriate conversion is not used. Fix it.
Also fix the function that inserts an unchecked conversion, in cases where
it could skip sliding due to the target type having fixed lower bound.
gcc/ada/
* inline.adb (Establish_Actual_Mapping_For_Inlined_Call): In the
case of formal with a fixed lower bounds, insert appropriate
conversion like in the case of a constrained type.
* tbuild.adb (Unchecked_Convert_To): Do not skip the conversion
when it may involve sliding due to a type with fixed lower bound.
Diffstat (limited to 'gcc/ada/tbuild.adb')
-rw-r--r-- | gcc/ada/tbuild.adb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/ada/tbuild.adb b/gcc/ada/tbuild.adb index 51fa43c..b538911 100644 --- a/gcc/ada/tbuild.adb +++ b/gcc/ada/tbuild.adb @@ -918,11 +918,17 @@ package body Tbuild is Result : Node_Id; begin - -- If the expression is already of the correct type, then nothing - -- to do, except for relocating the node + -- If the expression is already of the correct type, then nothing to do, + -- except for relocating the node. If Typ is an array type with fixed + -- lower bound, the expression might be of a subtype that does not + -- have this lower bound (on a slice), hence the conversion needs to + -- be preserved for sliding. if Present (Etype (Expr)) - and then (Base_Type (Etype (Expr)) = Typ or else Etype (Expr) = Typ) + and then + ((Base_Type (Etype (Expr)) = Typ + and then not Is_Fixed_Lower_Bound_Array_Subtype (Typ)) + or else Etype (Expr) = Typ) then return Relocate_Node (Expr); |