This series addresses the members_of_class ordering issue for imported
types as discussed in my previous patch thread [1].  As Nathaniel noted there,
storing TYPE_FIELDS in declaration order would make the problem trivial.

This series implements exactly that.

Besides my initial assumptions, the required changes are fairly minor, as most
legacy consumers of TYPE_FIELDS seem to be gone now.

Patch 1 makes the core change and updates the few sites that relied on
the old "stat-hack" ordering. 
Patch 2 then removes the now-redundant DECL_UID sort in class_members_of.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2026-March/710607.html

        Thomas


Thomas Berger (2):
  c++: store TYPE_FIELDS in declaration order
  c++/reflection: class_member_of/modules ordering

 gcc/analyzer/region-model.cc                  |  5 ++++
 gcc/cp/class.cc                               | 26 +------------------
 gcc/cp/decl.cc                                |  3 ++-
 gcc/cp/name-lookup.cc                         | 17 ++++++++++--
 gcc/cp/parser.cc                              | 20 +++++++-------
 gcc/cp/reflect.cc                             |  5 ----
 gcc/cp/semantics.cc                           | 20 ++------------
 .../g++.dg/modules/reflect-class-order_a.C    | 15 +++++++++++
 .../g++.dg/modules/reflect-class-order_b.C    | 24 +++++++++++++++++
 .../g++.dg/modules/reflect-clone-dtor_a.C     | 10 +++++++
 .../g++.dg/modules/reflect-clone-dtor_b.C     |  9 +++++++
 11 files changed, 94 insertions(+), 60 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/modules/reflect-class-order_a.C
 create mode 100644 gcc/testsuite/g++.dg/modules/reflect-class-order_b.C
 create mode 100644 gcc/testsuite/g++.dg/modules/reflect-clone-dtor_a.C
 create mode 100644 gcc/testsuite/g++.dg/modules/reflect-clone-dtor_b.C

-- 
2.52.0




Reply via email to