From patchwork Fri Jun 7 04:50:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 249597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 8B1222C0098 for ; Fri, 7 Jun 2013 14:50:35 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=qjvvH6nTkYxbN8HEOUs0Nb1y9wY+9Z 2TRXn84F1ORwkak/Wez4Kxx2GVsmWj8ZHL6l+vSR0L5gPHOp6LDR5B/N67qUXsCc sfUEei4BOg3aypjIAuhb0FOe6U4qJWODQwyU2Qq5kRXJsH2MWzy7gPpuIYAYDBuN g+yMYPPWszKM8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=E/fO3/mBACERbVCIHMOYb3u8ZSE=; b=jowy mv6SXeo1+OI6qAlbH3NEvMS0JxFfvZtyyPsyeoQNufPLevhX+MG7IrlI1aVpQ9lD yRg/+miynptJf6TOBLJoZq/clu6lLfchXmdH56T6DV0/sj1MDfIvSw/q6v3UVyDn D0Jo3w4ONt+bSzIqP4U1Zk2e88B4iMRT0QoogPk= Received: (qmail 1749 invoked by alias); 7 Jun 2013 04:50:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 1740 invoked by uid 89); 7 Jun 2013 04:50:29 -0000 X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_YE, SPF_PASS autolearn=ham version=3.3.1 Received: from mail-pd0-f172.google.com (HELO mail-pd0-f172.google.com) (209.85.192.172) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 07 Jun 2013 04:50:27 +0000 Received: by mail-pd0-f172.google.com with SMTP id z10so733416pdj.31 for ; Thu, 06 Jun 2013 21:50:25 -0700 (PDT) X-Received: by 10.66.231.7 with SMTP id tc7mr935196pac.143.1370580625682; Thu, 06 Jun 2013 21:50:25 -0700 (PDT) Received: from bubble.grove.modra.org ([101.166.26.37]) by mx.google.com with ESMTPSA id un15sm1270216pab.7.2013.06.06.21.50.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Jun 2013 21:50:24 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 9824AEA008F; Fri, 7 Jun 2013 14:20:20 +0930 (CST) Date: Fri, 7 Jun 2013 14:20:20 +0930 From: Alan Modra To: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] PR55033 Message-ID: <20130607045020.GL6878@bubble.grove.modra.org> Mail-Followup-To: gcc-patches@gcc.gnu.org References: <20130402033513.GT14552@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130402033513.GT14552@bubble.grove.modra.org> User-Agent: Mutt/1.5.21 (2010-09-15) On Tue, Apr 02, 2013 at 02:05:13PM +1030, Alan Modra wrote: > suspicious. For instance, you might wonder why it is correct to have > if (decl && !DECL_P (decl)) > decl = NULL_TREE; > before calling get_section(). The answer is that get_section() is not > prepared to handle !DECL_P trees when reporting errors. Arguably it > should be modified to do that. This patch tidies error reporting in get_section(), removing non-sensical messages like "foo causes a section type conflict with foo" which was one of the things we hit prior to my pr55033 fix. I'm moving the DECL_P check into error handling code. That seems like a win since decl and sect->named.decl are only used on the error path. Bootstrapped and regression tested powerpc64-linux. OK for mainline? * varasm.c (get_section): Don't die on !DECL_P decl. Tidy error reporting. (get_named_section): Don't NULL !DECL_P decl. Index: gcc/varasm.c =================================================================== --- gcc/varasm.c (revision 199718) +++ gcc/varasm.c (working copy) @@ -307,19 +307,22 @@ get_section (const char *name, unsigned int flags, return sect; } /* Sanity check user variables for flag changes. */ - if (decl == 0) - decl = sect->named.decl; - gcc_assert (decl); - if (sect->named.decl == NULL) + if (sect->named.decl != NULL + && DECL_P (sect->named.decl) + && decl != sect->named.decl) + { + if (decl != NULL && DECL_P (decl)) + error ("%+D causes a section type conflict with %D", + decl, sect->named.decl); + else + error ("section type conflict with %D", sect->named.decl); + inform (DECL_SOURCE_LOCATION (sect->named.decl), + "%qD was declared here", sect->named.decl); + } + else if (decl != NULL && DECL_P (decl)) error ("%+D causes a section type conflict", decl); else - { - error ("%+D causes a section type conflict with %D", - decl, sect->named.decl); - if (decl != sect->named.decl) - inform (DECL_SOURCE_LOCATION (sect->named.decl), - "%qD was declared here", sect->named.decl); - } + error ("section type conflict"); /* Make sure we don't error about one section multiple times. */ sect->common.flags |= SECTION_OVERRIDE; } @@ -409,9 +412,6 @@ get_named_section (tree decl, const char *name, in } flags = targetm.section_type_flags (decl, name, reloc); - - if (decl && !DECL_P (decl)) - decl = NULL_TREE; return get_section (name, flags, decl); }