From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1734) id D4C673858C50; Tue, 27 Sep 2022 13:24:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4C673858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664285067; bh=TyW2/qNgorBn5mR99AFwpa3Ogoy1mSxdtnPeahQiPjU=; h=From:To:Subject:Date:From; b=WJmfFEFLw4YJA8D7rst++uz28zwGMbDzkZrq8dc4PxjmdkETUfvi9Sin+W5ioqN/h fEUw/YDPqU50zsV7bNb1r8Mp9QZz2Xc+bzKxWp9KNSkvguZRCYd0V22REU3NJeT30N hcDhSfUxLr6U38/2yInPMo5SWNJr+bNfXowQtlpE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marek Polacek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2899] c++: Don't quote nothrow in diagnostic X-Act-Checkin: gcc X-Git-Author: Marek Polacek X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 3f7eea4411e4b2d8a500d9272b2ed72f73bdd008 X-Git-Newrev: 971bc0aae9cf52abe9a6fcab3b7c25d1fa94ad1e Message-Id: <20220927132427.D4C673858C50@sourceware.org> Date: Tue, 27 Sep 2022 13:24:27 +0000 (GMT) List-Id: https://gcc.gnu.org/g:971bc0aae9cf52abe9a6fcab3b7c25d1fa94ad1e commit r13-2899-g971bc0aae9cf52abe9a6fcab3b7c25d1fa94ad1e Author: Marek Polacek Date: Fri Sep 23 12:32:38 2022 -0400 c++: Don't quote nothrow in diagnostic In Jason noticed that we quote "nothrow" in diagnostics even though it's not a keyword in C++. This patch removes the quotes and also drops "nothrow" from c_keywords. gcc/c-family/ChangeLog: * c-format.cc (c_keywords): Drop nothrow. gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): Say "nothrow" without quotes rather than in quotes. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-traits3.C: Adjust expected diagnostics. Diff: --- gcc/c-family/c-format.cc | 3 +-- gcc/cp/constraint.cc | 14 +++++++------- gcc/testsuite/g++.dg/cpp2a/concepts-traits3.C | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc index a6c380bf1c8..a2026591ed1 100644 --- a/gcc/c-family/c-format.cc +++ b/gcc/c-family/c-format.cc @@ -2900,7 +2900,7 @@ static const token_t cxx_opers[] = }; /* Common C/C++ keywords that are expected to be quoted within the format - string. Keywords like auto, inline, or volatile are exccluded because + string. Keywords like auto, inline, or volatile are excluded because they are sometimes used in common terms like /auto variables/, /inline function/, or /volatile access/ where they should not be quoted. */ @@ -2927,7 +2927,6 @@ static const token_t c_keywords[] = NAME ("noinline", NULL), NAME ("nonnull", NULL), NAME ("noreturn", NULL), - NAME ("nothrow", NULL), NAME ("offsetof", NULL), NAME ("readonly", "read-only"), NAME ("readwrite", "read-write"), diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 5839bfb4b52..266ec581a20 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 nothrow copy assignable", t1); break; case CPTK_HAS_NOTHROW_CONSTRUCTOR: - inform (loc, " %qT is not % default constructible", t1); + inform (loc, " %qT is not nothrow default constructible", t1); break; case CPTK_HAS_NOTHROW_COPY: - inform (loc, " %qT is not % copy constructible", t1); + inform (loc, " %qT is not nothrow 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 nothrow 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 nothrow default constructible", t1); else - inform (loc, " %qT is not % constructible from %qE", t1, t2); + inform (loc, " %qT is not nothrow 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 nothrow 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..3e87da4611e 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 nothrow 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 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 } template concept UniqueObjReps = __has_unique_object_representations(T);