aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2010-01-10 19:37:45 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2010-01-10 19:37:45 +0000
commitab996409bcd1b433b9428fe1b4a5ca5b8e66e6e4 (patch)
tree65e7615616a5182e7423ac831a4eae0bcb5f6e58 /gcc/builtins.c
parent8b6f089bcbf20653a5a0e85d4390fe3b74e21bfc (diff)
downloadgcc-ab996409bcd1b433b9428fe1b4a5ca5b8e66e6e4.zip
gcc-ab996409bcd1b433b9428fe1b4a5ca5b8e66e6e4.tar.gz
gcc-ab996409bcd1b433b9428fe1b4a5ca5b8e66e6e4.tar.bz2
re PR middle-end/42667 (internal compiler error: in insert_into_preds_of_block, at tree-ssa-pre.c:3146)
2010-01-10 Richard Guenther <rguenther@suse.de> PR middle-end/42667 * builtins.c (fold_builtin_strlen): Add type argument and convert the resulting length to it. (fold_builtin_1): Adjust. * gcc.dg/torture/pr42667.c: New testcase. From-SVN: r155791
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 607117a..ac96934 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -135,7 +135,7 @@ static rtx expand_builtin_expect (tree, rtx);
static tree fold_builtin_constant_p (tree);
static tree fold_builtin_expect (location_t, tree, tree);
static tree fold_builtin_classify_type (tree);
-static tree fold_builtin_strlen (location_t, tree);
+static tree fold_builtin_strlen (location_t, tree, tree);
static tree fold_builtin_inf (location_t, tree, int);
static tree fold_builtin_nan (tree, tree, int);
static tree rewrite_call_expr (location_t, tree, int, tree, int, ...);
@@ -6617,7 +6617,7 @@ fold_builtin_classify_type (tree arg)
/* Fold a call to __builtin_strlen with argument ARG. */
static tree
-fold_builtin_strlen (location_t loc, tree arg)
+fold_builtin_strlen (location_t loc, tree type, tree arg)
{
if (!validate_arg (arg, POINTER_TYPE))
return NULL_TREE;
@@ -6626,12 +6626,7 @@ fold_builtin_strlen (location_t loc, tree arg)
tree len = c_strlen (arg, 0);
if (len)
- {
- /* Convert from the internal "sizetype" type to "size_t". */
- if (size_type_node)
- len = fold_convert_loc (loc, size_type_node, len);
- return len;
- }
+ return fold_convert_loc (loc, type, len);
return NULL_TREE;
}
@@ -9659,7 +9654,7 @@ fold_builtin_1 (location_t loc, tree fndecl, tree arg0, bool ignore)
return fold_builtin_classify_type (arg0);
case BUILT_IN_STRLEN:
- return fold_builtin_strlen (loc, arg0);
+ return fold_builtin_strlen (loc, type, arg0);
CASE_FLT_FN (BUILT_IN_FABS):
return fold_builtin_fabs (loc, arg0, type);