===================================================================
@@ -1605,6 +1605,18 @@ compute_record_mode (tree type)
|| ! tree_fits_uhwi_p (DECL_SIZE (field)))
return;
+ /* As a GNU extension, we support out-of-bounds accesses for a trailing
+ array with size 0 or 1. In this case, the record type effectively
+ has variable size so it needs to have BLKmode. */
+ if (!DECL_CHAIN (field) && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE)
+ {
+ tree domain_type = TYPE_DOMAIN (TREE_TYPE (field));
+ if (!TYPE_MAX_VALUE (domain_type)
+ || integer_zerop (TYPE_MAX_VALUE (domain_type))
+ || integer_onep (TYPE_MAX_VALUE (domain_type)))
+ return;
+ }
+
/* If this field is the whole struct, remember its mode so
that, say, we can put a double in a class into a DF
register instead of forcing it to live in the stack. */