From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: improve location of fold expressions
Date: Thu, 10 Mar 2022 15:01:05 -0500 [thread overview]
Message-ID: <649587d6-b0f9-257b-e057-853b51c4fba9@redhat.com> (raw)
In-Reply-To: <20220301041450.1407365-1-ppalka@redhat.com>
On 3/1/22 00:14, Patrick Palka wrote:
> This improves diagnostic quality for unsatisfied atomic constraints
> that consist of a fold expression, e.g. in concepts/diagnostics3.C:
>
> .../diagnostic3.C:10:22: note: the expression ‘(foo<Ts> && ...) [with Ts = {int, char}]’ evaluated to ‘false’
> 10 | requires (foo<Ts> && ...)
> | ~~~~~~~~~~~~^~~~
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk?
OK.
> gcc/cp/ChangeLog:
>
> * semantics.cc (finish_unary_fold_expr): Use input_location
> instead of UNKNOWN_LOCATION.
> (finish_binary_fold_expr): Likewise.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/concepts/diagnostic3.C: Adjusted expected location of
> "evaluated to false" diagnostics.
> ---
> gcc/cp/semantics.cc | 4 ++--
> gcc/testsuite/g++.dg/concepts/diagnostic3.C | 8 ++++----
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
> index a2c0eb050e6..07cae993efe 100644
> --- a/gcc/cp/semantics.cc
> +++ b/gcc/cp/semantics.cc
> @@ -12185,7 +12185,7 @@ finish_unary_fold_expr (tree expr, int op, tree_code dir)
>
> /* Build the fold expression. */
> tree code = build_int_cstu (integer_type_node, abs (op));
> - tree fold = build_min_nt_loc (UNKNOWN_LOCATION, dir, code, pack);
> + tree fold = build_min_nt_loc (input_location, dir, code, pack);
> FOLD_EXPR_MODIFY_P (fold) = (op < 0);
> TREE_TYPE (fold) = build_dependent_operator_type (NULL_TREE,
> FOLD_EXPR_OP (fold),
> @@ -12214,7 +12214,7 @@ finish_binary_fold_expr (tree pack, tree init, int op, tree_code dir)
> {
> pack = make_pack_expansion (pack);
> tree code = build_int_cstu (integer_type_node, abs (op));
> - tree fold = build_min_nt_loc (UNKNOWN_LOCATION, dir, code, pack, init);
> + tree fold = build_min_nt_loc (input_location, dir, code, pack, init);
> FOLD_EXPR_MODIFY_P (fold) = (op < 0);
> TREE_TYPE (fold) = build_dependent_operator_type (NULL_TREE,
> FOLD_EXPR_OP (fold),
> diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic3.C b/gcc/testsuite/g++.dg/concepts/diagnostic3.C
> index 7796e264251..410651a9c1a 100644
> --- a/gcc/testsuite/g++.dg/concepts/diagnostic3.C
> +++ b/gcc/testsuite/g++.dg/concepts/diagnostic3.C
> @@ -7,18 +7,18 @@ template<typename T>
> concept foo = (bool)(foo_v<T> | foo_v<T&>);
>
> template<typename... Ts>
> -requires (foo<Ts> && ...)
> +requires (foo<Ts> && ...) // { dg-message "with Ts = .int, char... evaluated to .false." }
> void
> -bar() // { dg-message "with Ts = .int, char... evaluated to .false." }
> +bar()
> { }
>
> template<int>
> struct S { };
>
> template<int... Is>
> -requires (foo<S<Is>> && ...)
> +requires (foo<S<Is>> && ...) // { dg-message "with Is = .2, 3, 4... evaluated to .false." }
> void
> -baz() // { dg-message "with Is = .2, 3, 4... evaluated to .false." }
> +baz()
> { }
>
> void
prev parent reply other threads:[~2022-03-10 20:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 4:14 Patrick Palka
2022-03-10 20:01 ` Jason Merrill [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=649587d6-b0f9-257b-e057-853b51c4fba9@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ppalka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).