aboutsummaryrefslogtreecommitdiff
path: root/gcc/input.c
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2021-09-03 18:25:10 +0200
committerThomas Schwinge <thomas@codesourcery.com>2021-09-20 10:12:47 +0200
commit7d79c3ebc3f3f6f8aecf83726c97474ae5cfe957 (patch)
tree1f8d1751e7b092c0fd11e6c37cec6434845b98c5 /gcc/input.c
parentf92901a508305f291fcf2acae0825379477724de (diff)
downloadgcc-7d79c3ebc3f3f6f8aecf83726c97474ae5cfe957.zip
gcc-7d79c3ebc3f3f6f8aecf83726c97474ae5cfe957.tar.gz
gcc-7d79c3ebc3f3f6f8aecf83726c97474ae5cfe957.tar.bz2
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.
Diffstat (limited to 'gcc/input.c')
-rw-r--r--gcc/input.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/input.c b/gcc/input.c
index 4b80986..dd753de 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)