SIZE to the size of the accessed element. */
inner_offset = 0;
type = TREE_TYPE (val);
- size = elt_size.to_uhwi () * BITS_PER_UNIT;
+ size = elt_sz * BITS_PER_UNIT;
}
+ else if (size && access_index < CONSTRUCTOR_NELTS (ctor) - 1
+ && TREE_CODE (val) == CONSTRUCTOR
+ && (elt_sz * BITS_PER_UNIT - inner_offset) < size)
+ /* If this isn't the last element in the CTOR and a CTOR itself
+ and it does not cover the whole object we are requesting give up
+ since we're not set up for combining from multiple CTORs. */
+ return NULL_TREE;
- *suboff += (access_index * elt_size * BITS_PER_UNIT).to_uhwi ();
+ *suboff += access_index.to_uhwi () * elt_sz * BITS_PER_UNIT;
return fold_ctor_reference (type, val, inner_offset, size, from_decl,
suboff);
}
--- /dev/null
+/* { dg-do run } */
+
+typedef int T;
+static const T a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
+typedef T v2 __attribute__((vector_size(2*sizeof(T))));
+
+int
+main()
+{
+ const T *p = &a[0][2];
+ v2 x = *(const v2 *)p;
+ T z = x[1];
+ if (z != 4)
+ __builtin_abort ();
+ return 0;
+}