diff options
author | Martin Sebor <msebor@redhat.com> | 2018-08-28 00:10:46 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2018-08-27 18:10:46 -0600 |
commit | 1583124e4fdfa4c60f7cfa4063e3ef47087927ca (patch) | |
tree | 79a8a2437a23485a87f39f56eb6b737742601de4 /gcc/builtins.c | |
parent | bdd039843c2df9c7ab1ebcd914a70208aaa14c23 (diff) | |
download | gcc-1583124e4fdfa4c60f7cfa4063e3ef47087927ca.zip gcc-1583124e4fdfa4c60f7cfa4063e3ef47087927ca.tar.gz gcc-1583124e4fdfa4c60f7cfa4063e3ef47087927ca.tar.bz2 |
PR tree-optimization/87112 - ICE in fold_binary_loc on strnlen of mixed integer types
gcc/ChangeLog:
PR tree-optimization/87112
* builtins.c (expand_builtin_strnlen): Convert c_strlen result to
the type of the bound argument.
gcc/testsuite/ChangeLog:
PR tree-optimization/87112
* gcc.dg/pr87112.c: New test.
From-SVN: r263900
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index c4b52b9..eb69a40 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -2970,6 +2970,10 @@ expand_builtin_strnlen (tree exp, rtx target, machine_mode target_mode) tree func = get_callee_fndecl (exp); tree len = c_strlen (src, 0); + /* FIXME: Change c_strlen() to return sizetype instead of ssizetype + so these conversions aren't necessary. */ + if (len) + len = fold_convert_loc (loc, TREE_TYPE (bound), len); if (TREE_CODE (bound) == INTEGER_CST) { @@ -2984,7 +2988,6 @@ expand_builtin_strnlen (tree exp, rtx target, machine_mode target_mode) if (!len || TREE_CODE (len) != INTEGER_CST) return NULL_RTX; - len = fold_convert_loc (loc, size_type_node, len); len = fold_build2_loc (loc, MIN_EXPR, size_type_node, len, bound); return expand_expr (len, target, target_mode, EXPAND_NORMAL); } |