On Wed, Oct 29, 2025 at 5:12 PM Martin Jambor <[email protected]> wrote: > > Hello, > > in a follow-up patch, I have created a GTYed subclass which does not > have any garbage collectible fields, just integers (a "sibling" > subclass does). This leads to gengtype outputting code like this to > gtype-desc.cc: > > 2722 case CIIK_SIMPLE: > 2723 { > 2724 cgraph_simple_indirect_info *sub = static_cast > <cgraph_simple_indirect_info *> (x); > 2725 } > 2726 break; > > And because in stage2 of our bootstrap we compile the file with -Wall > -Werror, this leads to a bootstrap failure because of > -Werror=unused-variable. > > I have briefly looked into building that particular file with > -Wno-error but did not found a simple way to do that, at least not > yet. > > So instead this patch generates statement "(void) sub;" after each > such static_assert to avoid the warning in the first place. > > Bootstrapped and LTO-bootstrapped and tested on x86_64-linux, OK for > master?
I think we might currently use GTY((skip)) for such subclasses to avoid this? But maybe the situation is so this workaround doesn't work. Anyway, the patch is sensible and OK if the rest is approved and some GTY skip trick doesn't work. Richard. > Martin > > > > gcc/ChangeLog: > > 2025-10-17 Martin Jambor <[email protected]> > > * gengtype.cc (walk_subclasses): Avoid generating code with unused > variables. > --- > gcc/gengtype.cc | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/gcc/gengtype.cc b/gcc/gengtype.cc > index 84c76362047..0f841fa2c2d 100644 > --- a/gcc/gengtype.cc > +++ b/gcc/gengtype.cc > @@ -2635,6 +2635,7 @@ walk_subclasses (type_p base, struct walk_type_data *d, > d->indent += 2; > oprintf (d->of, "%*s%s *sub = static_cast <%s *> (x);\n", > d->indent, "", sub->u.s.tag, sub->u.s.tag); > + oprintf (d->of, "%*s(void) sub;\n", d->indent, ""); > const char *old_val = d->val; > d->val = "(*sub)"; > walk_type (sub, d); > -- > 2.51.0 >
