public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3678] Don't record string concatenation data for 'RESERVED_LOCATION_P' Date: Mon, 20 Sep 2021 08:14:09 +0000 (GMT) [thread overview] Message-ID: <20210920081409.509F23858409@sourceware.org> (raw) https://gcc.gnu.org/g:7d79c3ebc3f3f6f8aecf83726c97474ae5cfe957 commit r12-3678-g7d79c3ebc3f3f6f8aecf83726c97474ae5cfe957 Author: Thomas Schwinge <thomas@codesourcery.com> Date: Fri Sep 3 18:25:10 2021 +0200 Don't record string concatenation data for 'RESERVED_LOCATION_P' 'RESERVED_LOCATION_P' means 'UNKNOWN_LOCATION' or 'BUILTINS_LOCATION'. We're using 'UNKNOWN_LOCATION' as a spare value for 'Empty', so should ascertain that we don't use it as a key additionally. Similarly for 'BUILTINS_LOCATION' that we'd later like to use as a spare value for 'Deleted'. As discussed in the source code comment added, for these we didn't have stable behavior anyway. Follow-up to r239175 (commit 88fa5555a309e5d6c6171b957daaf2f800920869) "On-demand locations within string-literals". gcc/ * input.c (string_concat_db::record_string_concatenation) (string_concat_db::get_string_concatenation): Skip for 'RESERVED_LOCATION_P'. gcc/testsuite/ * gcc.dg/plugin/diagnostic-test-string-literals-1.c: Adjust expected error diagnostics. Diff: --- gcc/input.c | 9 +++++++++ gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/input.c b/gcc/input.c index 4b809862e02..dd753decfa0 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -1437,6 +1437,11 @@ string_concat_db::record_string_concatenation (int num, location_t *locs) gcc_assert (locs); location_t key_loc = get_key_loc (locs[0]); + /* We don't record data for 'RESERVED_LOCATION_P (key_loc)' key values: + any data now recorded under key 'key_loc' would be overwritten by a + subsequent call with the same key 'key_loc'. */ + if (RESERVED_LOCATION_P (key_loc)) + return; string_concat *concat = new (ggc_alloc <string_concat> ()) string_concat (num, locs); @@ -1460,6 +1465,10 @@ string_concat_db::get_string_concatenation (location_t loc, gcc_assert (out_locs); location_t key_loc = get_key_loc (loc); + /* We don't record data for 'RESERVED_LOCATION_P (key_loc)' key values; see + discussion in 'string_concat_db::record_string_concatenation'. */ + if (RESERVED_LOCATION_P (key_loc)) + return false; string_concat **concat = m_table->get (key_loc); if (!concat) diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c index 4cba87be2ae..8818192eb45 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c @@ -332,8 +332,8 @@ pr87652 (const char *stem, int counter) OFFSET + end_idx); \ } while (0) -/* { dg-error "unable to read substring location: unable to read source line" "" { target c } 329 } */ -/* { dg-error "unable to read substring location: failed to get ordinary maps" "" { target c++ } 329 } */ +/* { dg-error "unable to read substring location: failed to get ordinary maps" "" { target c } 329 } */ +/* { dg-error "unable to read substring location: macro expansion" "" { target c++ } 329 } */ /* { dg-begin-multiline-output "" } __emit_string_literal_range(__FILE__":%5d: " format, \ ^~~~~~~~
reply other threads:[~2021-09-20 8:14 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=20210920081409.509F23858409@sourceware.org \ --to=tschwinge@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).