base = get_ref_base_and_extent (t, &offset, &size, &max_size, &reverse);
ctor = get_base_constructor (base, &offset, valueize);
+ /* We cannot determine ctor. */
+ if (!ctor)
+ return NULL_TREE;
/* Empty constructor. Always fold to 0. */
if (ctor == error_mark_node)
return build_zero_cst (TREE_TYPE (t));
- /* We do not know precise address. */
+ /* We do not know precise access. */
if (!known_size_p (max_size) || maybe_ne (max_size, size))
return NULL_TREE;
- /* We cannot determine ctor. */
- if (!ctor)
- return NULL_TREE;
-
/* Out of bound array access. Value is undefined, but don't fold. */
if (maybe_lt (offset, 0))
return NULL_TREE;
+ /* Access with reverse storage order. */
+ if (reverse)
+ return NULL_TREE;
tem = fold_ctor_reference (TREE_TYPE (t), ctor, offset, size, base);
if (tem)
&& offset.is_constant (&coffset)
&& (coffset % BITS_PER_UNIT != 0
|| csize % BITS_PER_UNIT != 0)
- && !reverse
&& BYTES_BIG_ENDIAN == WORDS_BIG_ENDIAN)
{
poly_int64 bitoffset;
--- /dev/null
+-- { dg-do run }
+-- { dg-options "-O" }
+
+with Ada.Unchecked_Conversion;
+with Interfaces; use Interfaces;
+with System; use System;
+
+procedure SSO20 is
+
+ type Bytes_Ref is array (1 .. 4) of Unsigned_8
+ with Convention => Ada_Pass_By_Reference;
+
+ type U32_BE is record
+ Value : Unsigned_32;
+ end record
+ with
+ Pack,
+ Bit_Order => High_Order_First,
+ Scalar_Storage_Order => High_Order_First;
+
+ function Conv is new Ada.Unchecked_Conversion (Bytes_Ref, U32_BE);
+
+ function Value (B : Bytes_Ref) return Unsigned_32 is (Conv (B).Value);
+
+begin
+ if Value ((16#11#, 16#22#, 16#33#, 16#44#)) /= 16#11223344# then
+ raise Program_Error;
+ end if;
+end;