From: Andrew Pinski <pinskia@gmail.com>
To: Vit Kabele <vit.kabele@sysgo.com>
Cc: Marek Polacek <polacek@redhat.com>,
vit@kabele.me, GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c: Extend the -Wpadded message with actual padding size
Date: Wed, 22 Jun 2022 01:47:18 -0700 [thread overview]
Message-ID: <CA+=Sn1mtQ3C+6wfZRSeiY9bX_3Awn2JmcBRmquacSU0LzZ6TMg@mail.gmail.com> (raw)
In-Reply-To: <YrLUAxyN4sHXJBK5@czspare1-lap.sysgo.cz>
On Wed, Jun 22, 2022 at 1:34 AM Vit Kabele <vit.kabele@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
next prev parent reply other threads:[~2022-06-22 8:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 19:37 Vit Kabele
2022-06-17 12:56 ` Eric Gallager
2022-06-17 14:06 ` Marek Polacek
2022-06-20 13:50 ` Vit Kabele
2022-06-20 23:05 ` Andrew Pinski
2022-06-22 8:34 ` Vit Kabele
2022-06-22 8:47 ` Andrew Pinski [this message]
2022-06-22 11:50 ` [PATCH v2] " Vit Kabele
2022-06-27 8:04 ` [PATCH v3] " Vit Kabele
2022-07-09 17:07 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+=Sn1mtQ3C+6wfZRSeiY9bX_3Awn2JmcBRmquacSU0LzZ6TMg@mail.gmail.com' \
--to=pinskia@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=polacek@redhat.com \
--cc=vit.kabele@sysgo.com \
--cc=vit@kabele.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).