https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811
--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> --- On Mon, 13 Nov 2023, joseph at codesourcery dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811 > > --- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery > dot com> --- > The checks are in check_bitfield_type_and_width. I expect the attribute - > in this position a declaration attribute - gets applied after that (and > while applying it results in a change to the type, and thus in the > declaration being laid out again, this check doesn't get repeated). > > In this case, the existing check is correct but not sufficient. In > another case the check is arguably too early: > > struct s { int __attribute__ ((__mode__ (DI))) x : 50; }; > > Considering int __attribute__ ((__mode__ (DI))) as a DImode integer type, > that bit-field width is valid - but it's rejected because the check is > carried out on int, before the attribute gets applied. Getting that case > to work might require extracting early those declaration attributes that > actually affect the type, so they can be applied to the type before the > declaration gets constructed and such checks are carried out. Ah, and when applying the vector_size attribute the FIELD_DECL hasn't been updated to indicate we identified it as bitfield (so we could reject the attribute) ... I'll leave this to frontend folks to sort out.