From patchwork Wed Nov 8 09:05:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 835732 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-466219-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="awGMhbAs"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yX0kT5Strz9sNw for ; Wed, 8 Nov 2017 20:05:20 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:cc:message-id:date:mime-version:content-type; q= dns; s=default; b=AW83zsCtBynoAtJqWkSlUVSj8GocV2uucQEilchxZwCftf Gw1ZU3gtCq0kYqxSGizuJfKU469dCCq7CAxuEjsKSGIKsZn0wHXMqHI/p1dQLyNV lVNpBlgqaSqQWCT/RNT9ZB1lOoYEb5dweQCFhDw6FHiXRDkyShRWp1CmsyAXc= 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:to :from:subject:cc:message-id:date:mime-version:content-type; s= default; bh=YdMNZa4mZik40KjekAd88oUUGsU=; b=awGMhbAsLccByvbR81e9 pLRMT8EtTIIf1HszBGXzpRY5HG29LdUU2CEpZbz66V5+tubn5ohmygRL/8RItAcL Meltr4EOYj7kBHP32zhAvlR8nBM3TYUxENUSEHuw3nIT97lmLzfwCXJz22kZIgWT KypNLkWkXfIK4CBnTLpYgWA= Received: (qmail 24328 invoked by alias); 8 Nov 2017 09:05:12 -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 24307 invoked by uid 89); 8 Nov 2017 09:05:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=xstr X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Nov 2017 09:05:10 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1eCMIG-0006mP-U5 from Tom_deVries@mentor.com ; Wed, 08 Nov 2017 01:05:08 -0800 Received: from [137.202.13.177] (137.202.0.87) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 8 Nov 2017 09:05:05 +0000 To: GCC Patches From: Tom de Vries Subject: [mips, committed] Wrap ASM_OUTPUT_LABELREF in do {} while (0) CC: Matthew Fortune Message-ID: <260a1abd-a80c-124f-c60d-8935bf90c081@mentor.com> Date: Wed, 8 Nov 2017 10:05:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) Hi, this patch wraps ASM_OUTPUT_LABELREF in a "do {} while (0)". Without, we can run into a dangling else, generating this kind of warning: ... $ cat test.c void bar (int); int c; #define barc \ if (c) \ bar (1); \ else \ bar (2) void foo (int d) { if (d) barc; } $ gcc test.c -S -Wall test.c: In function ‘foo’: test.c:14:6: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses] if (d) ^ ... Build for mips target. Committed as obvious. Thanks, - Tom [mips] Wrap ASM_OUTPUT_LABELREF in do {} while (0) 2017-11-07 Tom de Vries * config/mips/mips.h (ASM_OUTPUT_LABELREF): Wrap in "do {} while (0)". --- gcc/config/mips/mips.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index c1fcb86..bea2ce8 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -2566,12 +2566,15 @@ typedef struct mips_args { /* This handles the magic '..CURRENT_FUNCTION' symbol, which means 'the start of the function that this code is output in'. */ -#define ASM_OUTPUT_LABELREF(FILE,NAME) \ - if (strcmp (NAME, "..CURRENT_FUNCTION") == 0) \ - asm_fprintf ((FILE), "%U%s", \ - XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \ - else \ - asm_fprintf ((FILE), "%U%s", (NAME)) +#define ASM_OUTPUT_LABELREF(FILE,NAME) \ + do { \ + if (strcmp (NAME, "..CURRENT_FUNCTION") == 0) \ + asm_fprintf ((FILE), "%U%s", \ + XSTR (XEXP (DECL_RTL (current_function_decl), \ + 0), 0)); \ + else \ + asm_fprintf ((FILE), "%U%s", (NAME)); \ + } while (0) /* Flag to mark a function decl symbol that requires a long call. */ #define SYMBOL_FLAG_LONG_CALL (SYMBOL_FLAG_MACH_DEP << 0)