* [PATCH] c++: improve location of fold expressions
@ 2022-03-01 4:14 Patrick Palka
2022-03-10 20:01 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2022-03-01 4:14 UTC (permalink / raw)
To: gcc-patches
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?
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
--
2.35.1.354.g715d08a9e5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: improve location of fold expressions
2022-03-01 4:14 [PATCH] c++: improve location of fold expressions Patrick Palka
@ 2022-03-10 20:01 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2022-03-10 20:01 UTC (permalink / raw)
To: Patrick Palka, gcc-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-10 20:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 4:14 [PATCH] c++: improve location of fold expressions Patrick Palka
2022-03-10 20:01 ` Jason Merrill
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).