On Mon, 2026-03-16 at 14:40 -0400, Jason Merrill wrote: > On 3/15/26 7:57 AM, Thomas Berger wrote: > > Previously, finish_member_declaration prepended non-type members > > and > > appended TYPE_DECLs to TYPE_FIELDS separately, so that the > > TYPE_DECLs > > always appeared after all non-type members regardless of their > > decleration > > order. > > > > Store all members in declaration order instead and update the > > places, > > that relied on the old layout. > > > > gcc/analyzer/ChangeLog: > > > > * region-model.cc (struct_or_union_with_inheritance_p): > > Skip > > leading TYPE_DECL nodes before checking for base class > > field. > > > > gcc/cp/ChangeLog: > > > > * class.cc (unreverse_member_declarations): Use nreverse > > for both > > CLASSTYPE_DECL_LIST and TYPE_FIELDS. > > * decl.cc (reshape_init_class): Guard anonymous aggregate > > field > > search with FIELD_DECL check. > > * name-lookup.cc (fields_linear_search): Return first non- > > type > > match immediately; fall back to TYPE_DECL if no non-type > > is found. > > * parser.cc (remove_dummy_lambda_op): Search chain for > > dummy > > operator instead of assuming it is the TYPE_FIELDS head. > > * semantics.cc (finish_member_declaration): Always prepend > > to > > FIELD_DECL; remove separate handling for TYPE_DECL. > > > > Signed-off-by: Thomas Berger <[email protected]> > > --- > > 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/semantics.cc | 20 ++------------------ > > 6 files changed, 36 insertions(+), 55 deletions(-) > > > > diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region- > > model.cc > > index 4a6f5b4800c..1935b3a45fa 100644 > > --- a/gcc/analyzer/region-model.cc > > +++ b/gcc/analyzer/region-model.cc > > @@ -4116,6 +4116,11 @@ static bool > > struct_or_union_with_inheritance_p (tree struc) > > { > > tree iter = TYPE_FIELDS (struc); > > + > > + // look for the first non type member > > In general comments need to start with a capital letter and end with > period. This comment in particular seems unnecessary, since it > doesn't > say anything more than the next line. > > > + while (iter && TREE_CODE (iter) == TYPE_DECL) > > Let's make this != FIELD_DECL, since that's what the function is > looking > for. Does that sound right to you, David?
I think this is missing an update to the existing "while" loop in struct_or_union_with_inheritance_p. If there are non-field decls appearing after a trailing array, that could cause false negatives. If I'm understanding the rest of the patch correctly, I think we want to update the assignment to last_field in the existing while loop so that it's only set when iter is a FIELD_DECL. Dave > > > + iter = DECL_CHAIN (iter); > > + > > if (iter == NULL_TREE) > > return false; > > if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (iter)))
