if (TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (arg, 0))))
{
if (!AGGREGATE_TYPE_P (TREE_TYPE (arg))
+ && !POINTER_TYPE_P (TREE_TYPE (arg))
&& !VECTOR_TYPE_P (TREE_TYPE (arg)))
{
error_at (location, "cannot take address of scalar with "
possible for these fields to have a different scalar storage order than the
enclosing type.
+Note that neither pointer nor vector fields are considered scalar fields in
+this context, so the attribute has no effects on these fields.
+
This attribute is supported only for targets that use a uniform default
scalar storage order (fortunately, most of them), i.e.@: targets that store
the scalars either all in big-endian or all in little-endian.
--- /dev/null
+/* Test scalar_storage_order attribute and pointer fields */
+
+/* { dg-do run } */
+/* { dg-options "-Wno-pedantic" } */
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+struct __attribute__((scalar_storage_order("big-endian"))) Rec
+{
+ int *p;
+};
+#else
+struct __attribute__((scalar_storage_order("little-endian"))) Rec
+{
+ int *p;
+};
+#endif
+
+int main (int argc)
+{
+ struct Rec r = { &argc };
+ int *p = &argc;
+
+ if (__builtin_memcmp (&r.p, &p, sizeof (int *)) != 0)
+ __builtin_abort ();
+
+ return 0;
+}
reverse_storage_order_for_component_p (tree t)
{
/* The storage order only applies to scalar components. */
- if (AGGREGATE_TYPE_P (TREE_TYPE (t)) || VECTOR_TYPE_P (TREE_TYPE (t)))
+ if (AGGREGATE_TYPE_P (TREE_TYPE (t))
+ || POINTER_TYPE_P (TREE_TYPE (t))
+ || VECTOR_TYPE_P (TREE_TYPE (t)))
return false;
if (TREE_CODE (t) == REALPART_EXPR || TREE_CODE (t) == IMAGPART_EXPR)