On Wed, Jun 22, 2022 at 1:34 AM Vit Kabele <vit.kab...@sysgo.com> wrote: > > Hello, > > On Mon, Jun 20, 2022 at 04:05:17PM -0700, Andrew Pinski wrote: > > > new file mode 100644 > > > index 00000000000..e8f1044a36b > > > --- /dev/null > > > +++ b/gcc/testsuite/c-c++-common/Wpadded.c > > > @@ -0,0 +1,10 @@ > > > +/* { dg-do compile } */ > > > +/* { dg-options "-Wpadded" } */ > > > + > > > +/* > > > + * The struct is on single line, because C++ compiler emits the -Wpadded > > > + * warning at the first line of the struct, while the C compiler at the > > > last > > > + * line of the struct definition. This way the test passes on both > > > + */ > > > +struct S { __UINT32_TYPE__ i; char c; }; /* { dg-warning "padding struct > > > size to alignment boundary with 3 bytes" } */ > > > + > > Note the testcase will fail on some targets where alignment is 1 for > > everything. > > You most likely want the dg-warning to be like it is in gcc.dg/Wpadded.c: > > /* { dg-warning "padding struct size to alignment boundary with 3 > > bytes" "" { target { ! default_packed } } } */ > > > > You might want the following from the same file too: > > /* -fpack-struct is necessary because the warning expected requires the > > initial > > packing to be larger than 1, which cannot be guaranteed for all targets. > > We won't get a warning anyway if the target has "packed" structure > > layout. */ > > /* { dg-options "-Wpadded -fpack-struct=8" } */ > > /* { dg-additional-options "-mno-ms-bitfields" { target *-*-mingw* } } */ > I added the ! default_packed directive, but I am not sure whether the > -fpack-struct is needed. Could you please provide a name of the particular > target > with such alignment constraints so I can test it?
cris is one example. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23304 (which is why default_packed was added). Thanks, Andrew > > -- > Thank you, > Vit Kabele