]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: give fold expressions a location
authorPatrick Palka <ppalka@redhat.com>
Sat, 12 Mar 2022 19:57:56 +0000 (14:57 -0500)
committerPatrick Palka <ppalka@redhat.com>
Sat, 12 Mar 2022 19:57:56 +0000 (14:57 -0500)
This improves diagnostic quality for unsatisfied atomic constraints
that consist of a fold expression, e.g. in concepts/diagnostic3.C
the "evaluated to false" diagnostic now points to the expression:

  .../diagnostic3.C:10:22: note: the expression ‘(foo<Ts> && ...) [with Ts = {int, char}]’ evaluated to ‘false’
     10 | requires (foo<Ts> && ...)
        |          ~~~~~~~~~~~~^~~~

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
gcc/testsuite/g++.dg/concepts/diagnostic3.C

index da270e8f05c369fbb4851d221f7891fc4b2f1b8f..d5565ebe02d81bb2062c161f2424e858d6807fd3 100644 (file)
@@ -12197,7 +12197,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),
@@ -12226,7 +12226,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),
index 7796e2642519f6d634460e4d170d6d027977d513..410651a9c1adaeeb77b52d44df89f10cef0cd97c 100644 (file)
@@ -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