From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25639 invoked by alias); 14 Oct 2009 21:24:22 -0000 Received: (qmail 25630 invoked by uid 22791); 14 Oct 2009 21:24:21 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-vw0-f183.google.com (HELO mail-vw0-f183.google.com) (209.85.212.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Oct 2009 21:24:17 +0000 Received: by vws13 with SMTP id 13so94261vws.14 for ; Wed, 14 Oct 2009 14:24:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.69.227 with SMTP id a35mr13698142vcj.29.1255555455643; Wed, 14 Oct 2009 14:24:15 -0700 (PDT) In-Reply-To: <20091014205833.GH14664@tyan-ft48-01.lab.bos.redhat.com> References: <20091014205833.GH14664@tyan-ft48-01.lab.bos.redhat.com> Date: Wed, 14 Oct 2009 21:25:00 -0000 Message-ID: <84fc9c000910141424o667b3f04p24918188e6d253ad@mail.gmail.com> Subject: Re: [PATCH] Don't emit -Wpadded for builtin structs From: Richard Guenther To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2009-10/txt/msg00939.txt.bz2 On Wed, Oct 14, 2009 at 10:58 PM, Jakub Jelinek wrote: > Hi! > > The 3 tests below started FAILing after my recent BUILTINS_LOCATION > patch, the warnings are now reported at :0:0. =A0Instead of > adjusting the testcase, I think it is better not to warn about builtin > structs at all. =A0After all, what is it good for to let the user know? > The warning is meant to allow the user to better repack structs, but > obviously he can't do that with builtin structs, unless gcc sources are > changed. > > We then have ugly hacks like: > =A0/* Give the two bytes of padding a name, so that -Wpadded won't warn on > =A0 =A0 every user file. =A0*/ > =A0f_res =3D build_decl (BUILTINS_LOCATION, FIELD_DECL, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0get_identifier ("reserved"), s= hort_unsigned_type_node); > but it still doesn't cover many other cases, e.g. C++ RTTI, several > backends, etc. > > I've bootstrapped/regtested this on x86_64-linux and i686-linux. Ok. Thanks, Richard. > 2009-10-14 =A0Jakub Jelinek =A0 > > =A0 =A0 =A0 =A0* stor-layout.c (place_field): Don't emit -Wpadded warning= s for > =A0 =A0 =A0 =A0fields in builtin structs. > =A0 =A0 =A0 =A0(finalize_record_size): Likewise. > > =A0 =A0 =A0 =A0* obj-c++.dg/layout-1.mm: Don't xfail dg-bogus on lp64, ch= ange > =A0 =A0 =A0 =A0line from 1 to 0. > =A0 =A0 =A0 =A0* obj-c++.dg/bitfield-1.mm: Likewise. > =A0 =A0 =A0 =A0* obj-c++.dg/bitfield-4.mm: Likewise. > > --- gcc/stor-layout.c.jj =A0 =A0 =A0 =A02009-10-05 11:49:35.000000000 +02= 00 > +++ gcc/stor-layout.c =A0 2009-10-14 20:55:16.000000000 +0200 > @@ -1118,7 +1118,8 @@ place_field (record_layout_info rli, tre > =A0 =A0 =A0 /* No, we need to skip space before this field. > =A0 =A0 =A0 =A0 Bump the cumulative size to multiple of field alignment. = =A0*/ > > - =A0 =A0 =A0warning (OPT_Wpadded, "padding struct to align %q+D", field); > + =A0 =A0 =A0if (DECL_SOURCE_LOCATION (field) !=3D BUILTINS_LOCATION) > + =A0 =A0 =A0 warning (OPT_Wpadded, "padding struct to align %q+D", field= ); > > =A0 =A0 =A0 /* If the alignment is still within offset_align, just align > =A0 =A0 =A0 =A0 the bit position. =A0*/ > @@ -1483,7 +1484,8 @@ finalize_record_size (record_layout_info > =A0 =A0 =3D round_up_loc (input_location, unpadded_size_unit, TYPE_ALIGN_= UNIT (rli->t)); > > =A0 if (TREE_CONSTANT (unpadded_size) > - =A0 =A0 =A0&& simple_cst_equal (unpadded_size, TYPE_SIZE (rli->t)) =3D= =3D 0) > + =A0 =A0 =A0&& simple_cst_equal (unpadded_size, TYPE_SIZE (rli->t)) =3D= =3D 0 > + =A0 =A0 =A0&& input_location !=3D BUILTINS_LOCATION) > =A0 =A0 warning (OPT_Wpadded, "padding struct size to alignment boundary"= ); > > =A0 if (warn_packed && TREE_CODE (rli->t) =3D=3D RECORD_TYPE > --- gcc/testsuite/obj-c++.dg/layout-1.mm.jj =A0 =A0 2008-09-30 16:55:41.0= 00000000 +0200 > +++ gcc/testsuite/obj-c++.dg/layout-1.mm =A0 =A0 =A0 =A02009-10-14 22:50:= 42.000000000 +0200 > @@ -14,4 +14,4 @@ > =A0@end > > =A0/* { dg-prune-output "In output included from" } =A0 Ignore this messa= ge. =A0*/ > -/* { dg-bogus "padding struct to align" "PR23610" { xfail lp64 } 1 } */ > +/* { dg-bogus "padding struct to align" "PR23610" { target *-*-* } 0 } */ > --- gcc/testsuite/obj-c++.dg/bitfield-1.mm.jj =A0 2008-12-15 11:10:36.000= 000000 +0100 > +++ gcc/testsuite/obj-c++.dg/bitfield-1.mm =A0 =A0 =A02009-10-14 22:50:13= .000000000 +0200 > @@ -115,7 +115,7 @@ int main(void) > =A0} > > =A0/* { dg-prune-output "In file included from" } =A0Ignore this message.= =A0*/ > -/* { dg-bogus "padding struct to align" "PR23610" { xfail lp64 } 1 } */ > +/* { dg-bogus "padding struct to align" "PR23610" { target *-*-* } 0 } */ > =A0/* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 42 } */ > =A0/* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 45 } */ > =A0/* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 59 } */ > --- gcc/testsuite/obj-c++.dg/bitfield-4.mm.jj =A0 2008-09-30 16:55:41.000= 000000 +0200 > +++ gcc/testsuite/obj-c++.dg/bitfield-4.mm =A0 =A0 =A02009-10-14 22:50:31= .000000000 +0200 > @@ -50,7 +50,7 @@ int main(void) > =A0} > > =A0/* { dg-prune-output "In file included from" } =A0Ignore this message.= =A0*/ > -/* { dg-bogus "padding struct to align" "PR23610" { xfail lp64 } 1 } */ > +/* { dg-bogus "padding struct to align" "PR23610" { target *-*-* } 0 } */ > > =A0/* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 28 } */ > =A0/* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 34 } */ > > > =A0 =A0 =A0 =A0Jakub >