aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/lambda.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-11-14 23:18:19 -0500
committerJason Merrill <jason@redhat.com>2021-11-15 02:52:36 -0500
commit2317082c151e5580e0bfe5fcfbd0e9d0172446c9 (patch)
tree69059807d9ebc4345c55559282dec9b7519db46f /gcc/cp/lambda.c
parent37326651b439bac55d96fb5a43f4daf25e401eda (diff)
downloadgcc-2317082c151e5580e0bfe5fcfbd0e9d0172446c9.zip
gcc-2317082c151e5580e0bfe5fcfbd0e9d0172446c9.tar.gz
gcc-2317082c151e5580e0bfe5fcfbd0e9d0172446c9.tar.bz2
c++: location of lambda object and conversion call
Two things that had poor location info: we weren't giving the TARGET_EXPR for a lambda object any location, and the call to a conversion function was getting whatever input_location happened to be. gcc/cp/ChangeLog: * call.c (perform_implicit_conversion_flags): Use the location of the argument. * lambda.c (build_lambda_object): Set location on the TARGET_EXPR. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/lambda/lambda-switch.C: Adjust expected location.
Diffstat (limited to 'gcc/cp/lambda.c')
-rw-r--r--gcc/cp/lambda.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 2e9d38b..f68c68c 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -57,14 +57,13 @@ build_lambda_object (tree lambda_expr)
- cp_parser_functional_cast */
vec<constructor_elt, va_gc> *elts = NULL;
tree node, expr, type;
- location_t saved_loc;
if (processing_template_decl || lambda_expr == error_mark_node)
return lambda_expr;
/* Make sure any error messages refer to the lambda-introducer. */
- saved_loc = input_location;
- input_location = LAMBDA_EXPR_LOCATION (lambda_expr);
+ location_t loc = LAMBDA_EXPR_LOCATION (lambda_expr);
+ iloc_sentinel il (loc);
for (node = LAMBDA_EXPR_CAPTURE_LIST (lambda_expr);
node;
@@ -117,10 +116,10 @@ build_lambda_object (tree lambda_expr)
type = LAMBDA_EXPR_CLOSURE (lambda_expr);
CLASSTYPE_NON_AGGREGATE (type) = 0;
expr = finish_compound_literal (type, expr, tf_warning_or_error);
+ protected_set_expr_location (expr, loc);
CLASSTYPE_NON_AGGREGATE (type) = 1;
out:
- input_location = saved_loc;
return expr;
}