https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128772

--- Comment #6 from Uroš Bizjak <ubizjak at gmail dot com> ---
Created attachment 66192
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66192&action=edit
Combined (RFC) patch that ignores zero-length and flexible array members in arg
classification

A member that occupies no storage should contribute NO_CLASS, like an
empty structure or union.  classify_argument handled this
inconsistently:

- A zero-length array member (T a[0]) was classified by its element
  type when it was at a nonzero offset within an eightbyte, so
  struct { float x; int a[0]; } was returned in %eax instead of
  %xmm0.  The same happened for a union member at such an offset.
  clang ignores the member.

- A flexible array member (T a[]) has been ignored in structs since
  GCC 4.4, but only for the C front end.  The C++ front end gives the
  array no domain, so the check did not match and a struct with a
  flexible array member was classified as MEMORY.  A flexible array
  member in a union was never ignored, so the union was also classified
  as MEMORY.

Ignore all of these members in both the RECORD_TYPE and UNION_TYPE
loops and emit -Wpsabi notes about the ABI change.  The existing GCC 4.4
note is kept for C structs.  The zero-length notes are emitted only for
members at a nonzero offset within an eightbyte, since at offset 0 the
array was already classified as NO_CLASS.

Assisted-by: Claude Sonnet 5.5

Reply via email to