From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26492 invoked by alias); 14 Oct 2009 20:58:40 -0000 Received: (qmail 26484 invoked by uid 22791); 14 Oct 2009 20:58:40 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Oct 2009 20:58:36 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9EKwYJs002630 for ; Wed, 14 Oct 2009 16:58:34 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9EKwX7M002311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 14 Oct 2009 16:58:34 -0400 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.2/8.14.2/Submit) id n9EKwXPm027641 for gcc-patches@gcc.gnu.org; Wed, 14 Oct 2009 22:58:33 +0200 Date: Wed, 14 Oct 2009 21:23:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Don't emit -Wpadded for builtin structs Message-ID: <20091014205833.GH14664@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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/msg00937.txt.bz2 Hi! The 3 tests below started FAILing after my recent BUILTINS_LOCATION patch, the warnings are now reported at :0:0. Instead of adjusting the testcase, I think it is better not to warn about builtin structs at all. After 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: /* Give the two bytes of padding a name, so that -Wpadded won't warn on every user file. */ f_res = build_decl (BUILTINS_LOCATION, FIELD_DECL, get_identifier ("reserved"), short_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. 2009-10-14 Jakub Jelinek * stor-layout.c (place_field): Don't emit -Wpadded warnings for fields in builtin structs. (finalize_record_size): Likewise. * obj-c++.dg/layout-1.mm: Don't xfail dg-bogus on lp64, change line from 1 to 0. * obj-c++.dg/bitfield-1.mm: Likewise. * obj-c++.dg/bitfield-4.mm: Likewise. --- gcc/stor-layout.c.jj 2009-10-05 11:49:35.000000000 +0200 +++ gcc/stor-layout.c 2009-10-14 20:55:16.000000000 +0200 @@ -1118,7 +1118,8 @@ place_field (record_layout_info rli, tre /* No, we need to skip space before this field. Bump the cumulative size to multiple of field alignment. */ - warning (OPT_Wpadded, "padding struct to align %q+D", field); + if (DECL_SOURCE_LOCATION (field) != BUILTINS_LOCATION) + warning (OPT_Wpadded, "padding struct to align %q+D", field); /* If the alignment is still within offset_align, just align the bit position. */ @@ -1483,7 +1484,8 @@ finalize_record_size (record_layout_info = round_up_loc (input_location, unpadded_size_unit, TYPE_ALIGN_UNIT (rli->t)); if (TREE_CONSTANT (unpadded_size) - && simple_cst_equal (unpadded_size, TYPE_SIZE (rli->t)) == 0) + && simple_cst_equal (unpadded_size, TYPE_SIZE (rli->t)) == 0 + && input_location != BUILTINS_LOCATION) warning (OPT_Wpadded, "padding struct size to alignment boundary"); if (warn_packed && TREE_CODE (rli->t) == RECORD_TYPE --- gcc/testsuite/obj-c++.dg/layout-1.mm.jj 2008-09-30 16:55:41.000000000 +0200 +++ gcc/testsuite/obj-c++.dg/layout-1.mm 2009-10-14 22:50:42.000000000 +0200 @@ -14,4 +14,4 @@ @end /* { dg-prune-output "In output included from" } Ignore this message. */ -/* { 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 2008-12-15 11:10:36.000000000 +0100 +++ gcc/testsuite/obj-c++.dg/bitfield-1.mm 2009-10-14 22:50:13.000000000 +0200 @@ -115,7 +115,7 @@ int main(void) } /* { dg-prune-output "In file included from" } Ignore this message. */ -/* { dg-bogus "padding struct to align" "PR23610" { xfail lp64 } 1 } */ +/* { dg-bogus "padding struct to align" "PR23610" { target *-*-* } 0 } */ /* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 42 } */ /* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 45 } */ /* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 59 } */ --- gcc/testsuite/obj-c++.dg/bitfield-4.mm.jj 2008-09-30 16:55:41.000000000 +0200 +++ gcc/testsuite/obj-c++.dg/bitfield-4.mm 2009-10-14 22:50:31.000000000 +0200 @@ -50,7 +50,7 @@ int main(void) } /* { dg-prune-output "In file included from" } Ignore this message. */ -/* { dg-bogus "padding struct to align" "PR23610" { xfail lp64 } 1 } */ +/* { dg-bogus "padding struct to align" "PR23610" { target *-*-* } 0 } */ /* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 28 } */ /* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 34 } */ Jakub