gcc/

         * config/loongarch/loongarch.cc
         (loongarch_flatten_aggregate_field): Ignore empty fields for
         RECORD_TYPE.

gcc/testsuite/

         * gcc.target/loongarch/zero-size-field-pass.c: New test.
         * gcc.target/loongarch/zero-size-field-ret.c: New test.
---
  gcc/config/loongarch/loongarch.cc             |  3 ++
  .../loongarch/zero-size-field-pass.c          | 30 +++++++++++++++++++
  .../loongarch/zero-size-field-ret.c           | 28 +++++++++++++++++
  3 files changed, 61 insertions(+)
  create mode 100644 gcc/testsuite/gcc.target/loongarch/zero-size-field-pass.c   create mode 100644 gcc/testsuite/gcc.target/loongarch/zero-size-field-ret.c

diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index f22150a60cc..57e4d9f82ce 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -326,6 +326,9 @@ loongarch_flatten_aggregate_field (const_tree type,
        for (tree f = TYPE_FIELDS (type); f; f = DECL_CHAIN (f))
         if (TREE_CODE (f) == FIELD_DECL)
           {
+           if (DECL_SIZE (f) && integer_zerop (DECL_SIZE (f)))
+             continue;
+

I think the modification should be below.

             if (!TYPE_P (TREE_TYPE (f)))
               return -1;

Thanks!

Lulu Cheng

Reply via email to