From patchwork Wed Jan 5 23:45:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 49612 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 5F51D3857C7B for ; Wed, 5 Jan 2022 23:46:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F51D3857C7B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641426376; bh=gZy93hcAyeCJ0c6Li3U3zWpNzNttCfWfVUc+cPglevQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=XaZg+dayyDeF7pf/Vh/KvWJ2FDGv5ARuvs5K2QwsK2aXQTjp3K35ZwldC4ecXrwiq GvfdIGV3/syntyP5z0LNi1taZF9KqKEyDXGtzJzlRp9VfwcsgpHbz0rQjL9H8WNsgQ iN+O137OX0DVcixGvyYaKIgVuCQI22RdeSvcG8MQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A0B733857C56 for ; Wed, 5 Jan 2022 23:45:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A0B733857C56 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-296-Ecz7uzcFNn6_VMEoP8F-pw-1; Wed, 05 Jan 2022 18:45:45 -0500 X-MC-Unique: Ecz7uzcFNn6_VMEoP8F-pw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03CDB5A064 for ; Wed, 5 Jan 2022 23:45:45 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.34.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id B876578C39 for ; Wed, 5 Jan 2022 23:45:44 +0000 (UTC) To: GCC Patches Subject: [PATCH] Avoid more -Wformat-diag warnings [PR103758] Date: Wed, 5 Jan 2022 18:45:34 -0500 Message-Id: <20220105234534.505414-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: Marek Polacek via Gcc-patches From: Marek Polacek Reply-To: Marek Polacek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Let's use "%, %, or %" rather than "[x|y|z]" as in the rest of our codebase. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/11? PR c++/103758 gcc/c-family/ChangeLog: * c-pragma.c (handle_pragma_scalar_storage_order): Use %< %> in diagnostic messages. (handle_pragma_diagnostic): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/sso-6.c: Update dg-warning. --- gcc/c-family/c-pragma.c | 16 ++++++++++------ gcc/testsuite/gcc.dg/sso-6.c | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) base-commit: 4ec62dbafe0cb3b79cc635dfb964ef6a7ccc2d40 diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index ecf4457aacd..8dde5b841b2 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -441,7 +441,8 @@ handle_pragma_scalar_storage_order (cpp_reader *ARG_UNUSED(dummy)) token = pragma_lex (&x); if (token != CPP_NAME) - GCC_BAD ("missing [big-endian|little-endian|default] after %<#pragma scalar_storage_order%>"); + GCC_BAD ("missing %, %, or % after " + "%<#pragma scalar_storage_order%>"); kind_string = IDENTIFIER_POINTER (x); if (strcmp (kind_string, "default") == 0) global_sso = default_sso; @@ -450,7 +451,8 @@ handle_pragma_scalar_storage_order (cpp_reader *ARG_UNUSED(dummy)) else if (strcmp (kind_string, "little") == 0) global_sso = SSO_LITTLE_ENDIAN; else - GCC_BAD ("expected [big-endian|little-endian|default] after %<#pragma scalar_storage_order%>"); + GCC_BAD ("expected %, %, or % after " + "%<#pragma scalar_storage_order%>"); } /* GCC supports two #pragma directives for renaming the external @@ -771,8 +773,9 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy)) if (token != CPP_NAME) { warning_at (loc, OPT_Wpragmas, - "missing [error|warning|ignored|push|pop|ignored_attributes]" - " after %<#pragma GCC diagnostic%>"); + "missing %, %, %, %, " + "%, or % after " + "%<#pragma GCC diagnostic%>"); return; } @@ -830,8 +833,9 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy)) else { warning_at (loc, OPT_Wpragmas, - "expected [error|warning|ignored|push|pop|ignored_attributes]" - " after %<#pragma GCC diagnostic%>"); + "expected %, %, %, %, " + "%, % after " + "%<#pragma GCC diagnostic%>"); return; } diff --git a/gcc/testsuite/gcc.dg/sso-6.c b/gcc/testsuite/gcc.dg/sso-6.c index e955fa93686..559253293b5 100644 --- a/gcc/testsuite/gcc.dg/sso-6.c +++ b/gcc/testsuite/gcc.dg/sso-6.c @@ -3,7 +3,7 @@ /* { dg-do run } */ /* { dg-require-effective-target int32plus } */ -#pragma scalar_storage_order /* { dg-warning "missing .big-endian.little-endian.default." } */ +#pragma scalar_storage_order /* { dg-warning "missing .big-endian., .little-endian., or .default." } */ #pragma scalar_storage_order big-endian @@ -36,7 +36,7 @@ struct S5 int i; }; -#pragma scalar_storage_order other /* { dg-warning "expected .big-endian.little-endian.default." } */ +#pragma scalar_storage_order other /* { dg-warning "expected .big-endian., .little-endian., or .default." } */ struct S1 my_s1 = { 0x12345678 }; struct S2 my_s2 = { 0x12345678 };