This puts the No_Truncation flag on the unchecked conversion built for
converting between the prefix of 'Valid_Scalars and the view of its type
as returned by Validated_View for scalar types. This is needed in order
to prevent GNAT-LLVM from masking out the bits outside the RM size of
the prefix, which is required here.
Tested on x86_64-pc-linux-gnu, committed on trunk
2020-06-05 Eric Botcazou <ebotca...@adacore.com>
gcc/ada/
* exp_attr.adb (Expand_N_Attribute_Reference) <Valid_Scalars>:
Set the No_Truncation flag on the unchecked conversion built for
scalar types.
--- gcc/ada/exp_attr.adb
+++ gcc/ada/exp_attr.adb
@@ -7185,6 +7185,12 @@ package body Exp_Attr is
Unchecked_Convert_To (Val_Typ, New_Copy_Tree (Pref)),
Attribute_Name => Name_Valid);
+ -- Required by LLVM although the sizes are the same???
+
+ if Nkind (Prefix (Expr)) = N_Unchecked_Type_Conversion then
+ Set_No_Truncation (Prefix (Expr));
+ end if;
+
-- Validate the scalar components of an array by iterating over all
-- dimensions of the array while checking individual components.