diff options
author | Jakub Jelinek <jakub@redhat.com> | 2011-10-04 17:25:53 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-10-04 17:25:53 +0200 |
commit | 80642376c0afb85fb894cc89d76ba8cfd5025069 (patch) | |
tree | f072adab37a8ccac026fd1df0c6cbd04caeea5db /gcc/builtins.c | |
parent | c17d253c7ac235322caca8248f34a9e83919714d (diff) | |
download | gcc-80642376c0afb85fb894cc89d76ba8cfd5025069.zip gcc-80642376c0afb85fb894cc89d76ba8cfd5025069.tar.gz gcc-80642376c0afb85fb894cc89d76ba8cfd5025069.tar.bz2 |
re PR middle-end/50604 (verify_gimple failed: type mismatch in binary expression)
PR tree-optimization/50604
* builtins.c (fold_builtin_strcpy, fold_builtin_stpcpy,
fold_builtin_strncpy, fold_builtin_stxcpy_chk): Ensure
last argument to memcpy has size_type_node type instead of
ssizetype.
* tree-ssa-strlen.c (handle_builtin_memcpy): Use size_type_node
instead of TREE_TYPE (len) as type for newlen.
* gcc.dg/pr50604.c: New test.
From-SVN: r179508
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index b79ce6f..3055927 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8288,7 +8288,8 @@ fold_builtin_strcpy (location_t loc, tree fndecl, tree dest, tree src, tree len) return NULL_TREE; } - len = size_binop_loc (loc, PLUS_EXPR, len, ssize_int (1)); + len = fold_convert_loc (loc, size_type_node, len); + len = size_binop_loc (loc, PLUS_EXPR, len, build_int_cst (size_type_node, 1)); return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), build_call_expr_loc (loc, fn, 3, dest, src, len)); } @@ -8319,7 +8320,9 @@ fold_builtin_stpcpy (location_t loc, tree fndecl, tree dest, tree src) if (!fn) return NULL_TREE; - lenp1 = size_binop_loc (loc, PLUS_EXPR, len, ssize_int (1)); + lenp1 = size_binop_loc (loc, PLUS_EXPR, + fold_convert_loc (loc, size_type_node, len), + build_int_cst (size_type_node, 1)); /* We use dest twice in building our expression. Save it from multiple expansions. */ dest = builtin_save_expr (dest); @@ -8375,6 +8378,8 @@ fold_builtin_strncpy (location_t loc, tree fndecl, tree dest, fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; if (!fn) return NULL_TREE; + + len = fold_convert_loc (loc, size_type_node, len); return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), build_call_expr_loc (loc, fn, 3, dest, src, len)); } @@ -12127,7 +12132,9 @@ fold_builtin_stxcpy_chk (location_t loc, tree fndecl, tree dest, if (!fn) return NULL_TREE; - len = size_binop_loc (loc, PLUS_EXPR, len, ssize_int (1)); + len = fold_convert_loc (loc, size_type_node, len); + len = size_binop_loc (loc, PLUS_EXPR, len, + build_int_cst (size_type_node, 1)); return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), build_call_expr_loc (loc, fn, 4, dest, src, len, size)); |