From patchwork Fri Sep 23 18:40:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 57979 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 C18943857BB2 for ; Fri, 23 Sep 2022 18:41:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C18943857BB2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663958464; bh=k1E5KYg6LAXR06eeMUdwBckcifdZmkrApEJPJ9kYumM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=LGKH8BC/FDreKNBcQT7f9U0U3Vml1syiKnQaEe6Tj26nCdOpZl1BvEj/MEkTmqJE/ d8tQB3EcrURVOSa2nPUrGwfwu7a5VvZsYnE9yhWdDftSZKa/Tr6fNppz0nbED90WW5 f0Ek9v+NZw7Pe23h5uqIbxfoAF20ekJQcg1Ky4Zg= 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 0F9EE3858D38 for ; Fri, 23 Sep 2022 18:40:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0F9EE3858D38 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-580-R8C6UZhHPaKXpamlsYqjlg-1; Fri, 23 Sep 2022 14:40:33 -0400 X-MC-Unique: R8C6UZhHPaKXpamlsYqjlg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C9E182A59544 for ; Fri, 23 Sep 2022 18:40:32 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.32.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id A26A0140EBF3; Fri, 23 Sep 2022 18:40:32 +0000 (UTC) To: Jason Merrill , GCC Patches Subject: [PATCH] c++: Don't quote nothrow in diagnostic Date: Fri, 23 Sep 2022 14:40:26 -0400 Message-Id: <20220923184026.379494-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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" In Jason noticed that we quote "nothrow" in diagnostics even though it's not a keyword in C++. Just removing the quotes didn't work because then -Wformat-diag complains, so this patch replaces it with "no-throw". Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): Say "no-throw" (without quotes) rather than "nothrow" in quotes. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-traits3.C: Adjust expected diagnostics. --- gcc/cp/constraint.cc | 14 +++++++------- gcc/testsuite/g++.dg/cpp2a/concepts-traits3.C | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) base-commit: 8a7bcf95a82c3dd68bd4bcfbd8432eb970575bc2 diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 5839bfb4b52..136647f7c9e 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3592,13 +3592,13 @@ diagnose_trait_expr (tree expr, tree args) switch (TRAIT_EXPR_KIND (expr)) { case CPTK_HAS_NOTHROW_ASSIGN: - inform (loc, " %qT is not % copy assignable", t1); + inform (loc, " %qT is not no-throw copy assignable", t1); break; case CPTK_HAS_NOTHROW_CONSTRUCTOR: - inform (loc, " %qT is not % default constructible", t1); + inform (loc, " %qT is not no-throw default constructible", t1); break; case CPTK_HAS_NOTHROW_COPY: - inform (loc, " %qT is not % copy constructible", t1); + inform (loc, " %qT is not no-throw copy constructible", t1); break; case CPTK_HAS_TRIVIAL_ASSIGN: inform (loc, " %qT is not trivially copy assignable", t1); @@ -3674,7 +3674,7 @@ diagnose_trait_expr (tree expr, tree args) inform (loc, " %qT is not trivially assignable from %qT", t1, t2); break; case CPTK_IS_NOTHROW_ASSIGNABLE: - inform (loc, " %qT is not % assignable from %qT", t1, t2); + inform (loc, " %qT is not no-throw assignable from %qT", t1, t2); break; case CPTK_IS_CONSTRUCTIBLE: if (!t2) @@ -3690,9 +3690,9 @@ diagnose_trait_expr (tree expr, tree args) break; case CPTK_IS_NOTHROW_CONSTRUCTIBLE: if (!t2) - inform (loc, " %qT is not % default constructible", t1); + inform (loc, " %qT is not no-throw default constructible", t1); else - inform (loc, " %qT is not % constructible from %qE", t1, t2); + inform (loc, " %qT is not no-throw constructible from %qE", t1, t2); break; case CPTK_HAS_UNIQUE_OBJ_REPRESENTATIONS: inform (loc, " %qT does not have unique object representations", t1); @@ -3701,7 +3701,7 @@ diagnose_trait_expr (tree expr, tree args) inform (loc, " %qT is not convertible from %qE", t2, t1); break; case CPTK_IS_NOTHROW_CONVERTIBLE: - inform (loc, " %qT is not % convertible from %qE", t2, t1); + inform (loc, " %qT is not no-throw convertible from %qE", t2, t1); break; case CPTK_REF_CONSTRUCTS_FROM_TEMPORARY: inform (loc, " %qT is not a reference that binds to a temporary " diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-traits3.C b/gcc/testsuite/g++.dg/cpp2a/concepts-traits3.C index f20608b6918..6ac849d71fd 100644 --- a/gcc/testsuite/g++.dg/cpp2a/concepts-traits3.C +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-traits3.C @@ -21,7 +21,7 @@ concept TriviallyAssignable = __is_trivially_assignable(T, U); template concept NothrowAssignable = __is_nothrow_assignable(T, U); -// { dg-message "'S' is not 'nothrow' assignable from 'int'" "" { target *-*-* } .-1 } +// { dg-message "'S' is not no-throw assignable from 'int'" "" { target *-*-* } .-1 } template concept Constructible = __is_constructible(T, Args...); @@ -37,9 +37,9 @@ concept TriviallyConstructible = __is_trivially_constructible(T, Args...); template concept NothrowConstructible = __is_nothrow_constructible(T, Args...); -// { dg-message "'S' is not 'nothrow' default constructible" "" { target *-*-* } .-1 } -// { dg-message "'S' is not 'nothrow' constructible from 'int'" "" { target *-*-* } .-2 } -// { dg-message "'S' is not 'nothrow' constructible from 'int, char'" "" { target *-*-* } .-3 } +// { dg-message "'S' is not no-throw default constructible" "" { target *-*-* } .-1 } +// { dg-message "'S' is not no-throw constructible from 'int'" "" { target *-*-* } .-2 } +// { dg-message "'S' is not no-throw constructible from 'int, char'" "" { target *-*-* } .-3 } template concept UniqueObjReps = __has_unique_object_representations(T);