From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95565 invoked by alias); 7 Aug 2016 07:14:43 -0000 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 Received: (qmail 95554 invoked by uid 89); 7 Aug 2016 07:14:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Sun, 07 Aug 2016 07:14:40 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 31064AAEF; Sun, 7 Aug 2016 07:14:37 +0000 (UTC) User-Agent: K-9 Mail for Android In-Reply-To: <20160806190908.GB14857@tucnak.redhat.com> References: <20160806190908.GB14857@tucnak.redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [PATCH] Allow relayout_decl on FIELD_DECLs (PR c/72816) From: Richard Biener Date: Sun, 07 Aug 2016 07:14:00 -0000 To: Jakub Jelinek ,"Joseph S. Myers" ,Marek Polacek CC: gcc-patches@gcc.gnu.org Message-ID: X-SW-Source: 2016-08/txt/msg00546.txt.bz2 On August 6, 2016 9:09:08 PM GMT+02:00, Jakub Jelinek wrote: >Hi! > >As the testcase shows, the C FE can call relayout_decl even on >FIELD_DECLs >in certain cases. Trying to call only layout_decl on FIELD_DECL and >relayout_decl on other decls would be insufficient, we'd need to repeat >there most of the relayout_decl code (except for SET_DECL_RTL, which >FIELD_DECLs don't have). > >So I think it is better to allow relayout_decl also on FIELD_DECLs. > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. Thanks, Richard. >2016-08-06 Jakub Jelinek > > PR c/72816 > * stor-layout.c (layout_decl): Fix up formatting. > (relayout_decl): Allow DECL to be FIELD_DECL. > > * gcc.dg/pr72816.c: New test. > >--- gcc/stor-layout.c.jj 2016-08-06 12:11:56.000000000 +0200 >+++ gcc/stor-layout.c 2016-08-06 13:04:43.662532852 +0200 >@@ -596,7 +596,7 @@ layout_decl (tree decl, unsigned int kno > return; > >gcc_assert (code == VAR_DECL || code == PARM_DECL || code == >RESULT_DECL >- || code == TYPE_DECL ||code == FIELD_DECL); >+ || code == TYPE_DECL || code == FIELD_DECL); > > rtl = DECL_RTL_IF_SET (decl); > >@@ -768,8 +768,8 @@ layout_decl (tree decl, unsigned int kno > } > } > >-/* Given a VAR_DECL, PARM_DECL or RESULT_DECL, clears the results of >- a previous call to layout_decl and calls it again. */ >+/* Given a VAR_DECL, PARM_DECL, RESULT_DECL, or FIELD_DECL, clears the >+ results of a previous call to layout_decl and calls it again. */ > > void > relayout_decl (tree decl) >@@ -778,7 +778,8 @@ relayout_decl (tree decl) > DECL_MODE (decl) = VOIDmode; > if (!DECL_USER_ALIGN (decl)) > SET_DECL_ALIGN (decl, 0); >- SET_DECL_RTL (decl, 0); >+ if (DECL_RTL_SET_P (decl)) >+ SET_DECL_RTL (decl, 0); > > layout_decl (decl, 0); > } >--- gcc/testsuite/gcc.dg/pr72816.c.jj 2016-08-06 13:06:45.046003282 >+0200 >+++ gcc/testsuite/gcc.dg/pr72816.c 2016-08-06 13:07:57.217093845 +0200 >@@ -0,0 +1,9 @@ >+/* PR c/72816 */ >+/* { dg-do compile } */ >+/* { dg-options "-std=gnu11" } */ >+ >+typedef const int A[]; >+struct S { >+ int a; >+ A b; /* { dg-error "array size missing" } */ >+}; > > Jakub