From patchwork Wed Jan 12 02:54:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 49893 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A7EBC3858029 for ; Wed, 12 Jan 2022 02:55:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7EBC3858029 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641956133; bh=h9TjFPk7eAQOSWFJQXebc4RZi4oZUSfmlhH2JmJVD0g=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=X8PPpnCacNLBwsUPG9q8vyrkJqADArtFPycqSX7yKrDFpXhcxRezf+DhOpvNOd96R Pz8JPYnWbDaWqhzWgUaOUnTtP2K+UmBsG5INkbSYeAj/7LsdG4LOikcabegDf7p77Z FLqykLcDgO7hlVM7SbIHvRtXtoVfSytf7e/hMFpw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by sourceware.org (Postfix) with ESMTPS id 70662385E44A for ; Wed, 12 Jan 2022 02:54:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 70662385E44A To: Subject: [Committed] cris: Avoid format-string-related warnings in calls to error functions MIME-Version: 1.0 Message-ID: <20220112025422.2AB862040E@pchp3.se.axis.com> Date: Wed, 12 Jan 2022 03:54:22 +0100 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Hans-Peter Nilsson via Gcc-patches From: Hans-Peter Nilsson Reply-To: Hans-Peter Nilsson Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" These tweaks are installed to avoid build-warnings for config/cris/cris.c, like: x/gcc/config/cris/cris.c: In function 'const char* cris_op_str(rtx)': x/gcc/config/cris/cris.c:728:23: warning: unquoted identifier or keyword \ 'cris_op_str' in format [-Wformat-diag] 728 | internal_error ("MULT case in cris_op_str"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ./tm.h:20, from x/gcc/backend.h:28, from x/gcc/config/cris/cris.c:26: x/gcc/config/cris/cris.c: In function 'void cris_expand_return(bool)': x/gcc/config/cris/cris.h:42:33: warning: unquoted operator '->' in \ format [-Wformat-diag] 42 | do { if (!(x)) internal_error ("CRIS-port assertion failed: " #x); \ } while (0) x/gcc/config/cris/cris.c:1862:3: note: in expansion of macro 'CRIS_ASSERT' 1862 | CRIS_ASSERT (cfun->machine->return_type != CRIS_RETINSN_RET \ || !on_stack); | ^~~~~~~~~~~ x/gcc/config/cris/cris.c: In function 'void cris_option_override()': x/gcc/config/cris/cris.c:2298:9: warning: space followed by punctuation \ character ':' [-Wformat-diag] 2298 | error ("unknown CRIS version specification in %<-march=%> or " | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2299 | "%<-mcpu=%> : %s", cris_cpu_str); | ~~~~~~~~~~~~~~~~~ x/gcc/config/cris/cris.c:2334:9: warning: space followed by punctuation \ character ':' [-Wformat-diag] 2334 | error ("unknown CRIS cpu version specification in %<-mtune=%> : %s", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ./tm.h:20, from x/gcc/backend.h:28, from x/gcc/config/cris/cris.c:26: x/gcc/config/cris/cris.c: In function 'rtx_def* cris_split_movdx(rtx_def**)': x/gcc/config/cris/cris.h:42:33: warning: unquoted identifier or keyword \ 'GET_CODE' in format [-Wformat-diag] 42 | do { if (!(x)) internal_error ("CRIS-port assertion failed: " #x); \ } while (0) x/gcc/config/cris/cris.c:2457:3: note: in expansion of macro 'CRIS_ASSERT' 2457 | CRIS_ASSERT (GET_CODE (dest) != SUBREG && GET_CODE (src) != SUBREG); | ^~~~~~~~~~~ Not that I therefore agree that operators, identifiers and keywords should have to be dressed up like this for internal error messages; they were more readable without these garments, if only slightly so. 2022-01-11 Hans-Peter Nilsson * config/cris/cris.c: Quote identifiers in parameters to error and internal_error, and remove extraneous spaces with punctuation. * config/cris/cris.h (CRIS_ASSERT): When passing on stringified expression to internal_error, pass it as a parameter instead of appending it to the format part. --- gcc/config/cris/cris.c | 8 ++++---- gcc/config/cris/cris.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index ac1fc4909fc3..63e6834b9cfb 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -725,7 +725,7 @@ cris_op_str (rtx x) an operator, for immediate output. If that ever happens for MULT, we need to apply TARGET_MUL_BUG in the caller. Make sure we notice. */ - internal_error ("MULT case in cris_op_str"); + internal_error ("MULT case in %"); break; case DIV: @@ -2213,7 +2213,7 @@ cris_side_effect_mode_ok (enum rtx_code code, rtx *ops, } /* If we get here, the caller got its initial tests wrong. */ - internal_error ("internal error: cris_side_effect_mode_ok with bad operands"); + internal_error ("internal error: % with bad operands"); } /* Queue an .ident string in the queue of top-level asm statements. @@ -2296,7 +2296,7 @@ cris_option_override (void) if (cris_cpu_version < 0 || cris_cpu_version > 10) error ("unknown CRIS version specification in %<-march=%> or " - "%<-mcpu=%> : %s", cris_cpu_str); + "%<-mcpu=%>: %s", cris_cpu_str); /* Set the target flags. */ if (cris_cpu_version >= CRIS_CPU_ETRAX4) @@ -2331,7 +2331,7 @@ cris_option_override (void) cris_tune = 10; if (cris_tune < 0 || cris_tune > 32) - error ("unknown CRIS cpu version specification in %<-mtune=%> : %s", + error ("unknown CRIS cpu version specification in %<-mtune=%>: %s", cris_tune_str); if (cris_tune >= CRIS_CPU_SVINTO) diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index c4d635ba0ae9..8235509f2337 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -39,7 +39,7 @@ along with GCC; see the file COPYING3. If not see /* We don't want to use gcc_assert for everything, as that can be compiled out. */ #define CRIS_ASSERT(x) \ - do { if (!(x)) internal_error ("CRIS-port assertion failed: " #x); } while (0) + do { if (!(x)) internal_error ("CRIS-port assertion failed: %s", #x); } while (0) /* Replacement for REG_P since it does not match SUBREGs. Happens for testcase Axis-20000320 with gcc-2.9x. */