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: 1425 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp361955wrt; Fri, 23 Sep 2022 11:41:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ZAanZe2GupgCSSGzBTPdGE0k+aTjw8mljeClVkjXj6FkIV8Q+iVLLgezTvMPoh7LeYgpx X-Received: by 2002:a17:907:7ea6:b0:782:a975:7426 with SMTP id qb38-20020a1709077ea600b00782a9757426mr3395602ejc.157.1663958482152; Fri, 23 Sep 2022 11:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663958482; cv=none; d=google.com; s=arc-20160816; b=N/uP+l0Jw97UAC6WP9Nk0z0qxpq43I6fb9aQDV3XQ06oJcNUVqHI1TCav6OisSQI3I o3fffbzoBV7EfWIRdAsro5yWQwIa+pS+fdN+FATt2UrCK3Ekfk5y0pTbSNS5Rl/+oyg3 dWdoLlESm6e+yMmCvAx5A44k8hz/7YmZWXga0vcW39Kn/7+ewS7uEdchQijOxNfhN3w8 WOAUGvq6+Yt+E1l3CMFBra++6REzzNG7kMWb7jHXf22Cza1FMUj03C2tDu4TJsWKu/t+ QS3M0EQ0J3MHghAoLKQBYl5gpdh31/EBPnKORSraPBbHk7q7OZqIv/1MfXlCMbjf9ARK cg5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=k1E5KYg6LAXR06eeMUdwBckcifdZmkrApEJPJ9kYumM=; b=HH8pfIb+rCJfDAwvk8toeIfny7n8yvRqGL5kFiSOo3EwIbtzBMXA7gt5G/ngQR5V/T C83gn495mzKMCd48NBbFKD5KM64jO2RnOWZyX0+NjOkbNddc6z7HHJ48ZJnZJG1Kjgn4 qsgKACQ+JxHIGJExhW/yzDLrCgjHBEXU9MPVKVzkUW1HNNtdqYWe/g/H9J6fpvnOhBRk aHJJr6gsFfvyCSPHe2mnhAmav1GR8kRXP2gWBCBgy+iDoZm3TWGdviVZYtKG8wv7599x aTVcIx6n6i0gbQvBEPI5+MC160qzTc2AVD3XfxToGX8ex8Cvu3i2hri5M4ogjMFIQvAR DXBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DF232raj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n23-20020aa7c457000000b00446bd8e291fsi7508146edr.526.2022.09.23.11.41.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 11:41:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DF232raj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 19A1B3857B8B for ; Fri, 23 Sep 2022 18:41:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19A1B3857B8B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663958479; bh=k1E5KYg6LAXR06eeMUdwBckcifdZmkrApEJPJ9kYumM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DF232raj//ipmP7ZH/IxZUTlZchL0eqLsPciPw2SZJGLIZnaJhhh4njxtKFv/Kyxk 7ZgQgtNSl8ICe4FBK/t84mv00P7Y98u/1dW1iUN6Y6QlNUZS1wXDlRynpgNdmaqwBJ hfY8sdyxsaiF2+jpjvLkZR4EtRy48LK79Nd5PyI8= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744786929174059143?= X-GMAIL-MSGID: =?utf-8?q?1744786929174059143?= 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);