public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5257] c++: location of lambda object and conversion call Date: Mon, 15 Nov 2021 07:53:20 +0000 (GMT) [thread overview] Message-ID: <20211115075320.50B373858029@sourceware.org> (raw) https://gcc.gnu.org/g:2317082c151e5580e0bfe5fcfbd0e9d0172446c9 commit r12-5257-g2317082c151e5580e0bfe5fcfbd0e9d0172446c9 Author: Jason Merrill <jason@redhat.com> Date: Sun Nov 14 23:18:19 2021 -0500 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. Diff: --- gcc/cp/call.c | 6 +++++- gcc/cp/lambda.c | 7 +++---- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-switch.C | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 01ac114a62c..4ee21c7bdbd 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -12549,7 +12549,11 @@ perform_implicit_conversion_flags (tree type, tree expr, IMPLICIT_CONV_EXPR_BRACED_INIT (expr) = true; } else - expr = convert_like (conv, expr, complain); + { + /* Give a conversion call the same location as expr. */ + iloc_sentinel il (loc); + expr = convert_like (conv, expr, complain); + } /* Free all the conversions we allocated. */ obstack_free (&conversion_obstack, p); diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 2e9d38bbe83..f68c68ca16e 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; } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-switch.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-switch.C index d05c9760709..e417967a17e 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-switch.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-switch.C @@ -16,11 +16,11 @@ main () break; // { dg-error "break" } } }; - l = []() + l = []() // { dg-warning "statement will never be executed" } { case 3: // { dg-error "case" } break; // { dg-error "break" } - }; // { dg-warning "statement will never be executed" } + }; } } }
reply other threads:[~2021-11-15 7:53 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211115075320.50B373858029@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).