diff options
author | Martin Sebor <msebor@redhat.com> | 2020-07-20 12:06:18 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2020-07-20 12:08:58 -0600 |
commit | d5803b9876b3d11c93d1a10fabb3fbb1c4a14bd6 (patch) | |
tree | 21c9c55bfd9003436d22c960d3578579af9dd744 /gcc/tree.h | |
parent | 3e99ed65cbedf7a6c0abb9cd63c191326995fd34 (diff) | |
download | gcc-d5803b9876b3d11c93d1a10fabb3fbb1c4a14bd6.zip gcc-d5803b9876b3d11c93d1a10fabb3fbb1c4a14bd6.tar.gz gcc-d5803b9876b3d11c93d1a10fabb3fbb1c4a14bd6.tar.bz2 |
Correct handling of constant representations containing embedded nuls.
Resolves:
PR middle-end/95189 - memcmp being wrongly stripped like strcm
PR middle-end/95886 - suboptimal memcpy with embedded zero bytes
gcc/ChangeLog:
PR middle-end/95189
PR middle-end/95886
* builtins.c (inline_expand_builtin_string_cmp): Rename...
(inline_expand_builtin_bytecmp): ...to this.
(builtin_memcpy_read_str): Don't expect data to be nul-terminated.
(expand_builtin_memory_copy_args): Handle object representations
with embedded nul bytes.
(expand_builtin_memcmp): Same.
(expand_builtin_strcmp): Adjust call to naming change.
(expand_builtin_strncmp): Same.
* expr.c (string_constant): Create empty strings with nonzero size.
* fold-const.c (c_getstr): Rename locals and update comments.
* tree.c (build_string): Accept null pointer argument.
(build_string_literal): Same.
* tree.h (build_string): Provide a default.
(build_string_literal): Same.
gcc/testsuite/ChangeLog:
PR middle-end/95189
PR middle-end/95886
* gcc.dg/memcmp-pr95189.c: New test.
* gcc.dg/strncmp-3.c: New test.
* gcc.target/i386/memcpy-pr95886.c: New test.
Diffstat (limited to 'gcc/tree.h')
-rw-r--r-- | gcc/tree.h | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -4425,7 +4425,7 @@ extern tree build_one_cst (tree); extern tree build_minus_one_cst (tree); extern tree build_all_ones_cst (tree); extern tree build_zero_cst (tree); -extern tree build_string (int, const char *); +extern tree build_string (unsigned, const char * = NULL); extern tree build_poly_int_cst (tree, const poly_wide_int_ref &); extern tree build_tree_list (tree, tree CXX_MEM_STAT_INFO); extern tree build_tree_list_vec (const vec<tree, va_gc> * CXX_MEM_STAT_INFO); @@ -4456,7 +4456,8 @@ extern tree build_call_expr_internal_loc_array (location_t, enum internal_fn, extern tree maybe_build_call_expr_loc (location_t, combined_fn, tree, int, ...); extern tree build_alloca_call_expr (tree, unsigned int, HOST_WIDE_INT); -extern tree build_string_literal (int, const char *, tree = char_type_node, +extern tree build_string_literal (unsigned, const char * = NULL, + tree = char_type_node, unsigned HOST_WIDE_INT = HOST_WIDE_INT_M1U); /* Construct various nodes representing data types. */ |