]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/42667 (internal compiler error: in insert_into_preds_of_block, at...
authorRichard Guenther <rguenther@suse.de>
Sun, 10 Jan 2010 19:37:45 +0000 (19:37 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Sun, 10 Jan 2010 19:37:45 +0000 (19:37 +0000)
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

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr42667.c [new file with mode: 0644]

index 73263cd050515060a46827d5946166baf1ad1540..8869f7fa9d6d242e65dc85606a465f8c5a14c880 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2010-01-09  Jakub Jelinek  <jakub@redhat.com>
 
        * config/rs6000/rs6000.c (rs6000_emit_set_long_const): Shorten
index 607117a4017cf0f60638b1021ad0326bb909cf29..ac9693400e4a0159ef985b60336d27def6a78398 100644 (file)
@@ -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);
index f3a033e02502bf7352ac3c157949da82a9f9affa..c2effe95337e6ba957701cae280e9b98fabe20e6 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-10  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/42667
+       * gcc.dg/torture/pr42667.c: New testcase.
+
 2010-01-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>
 
        PR fortran/32489
diff --git a/gcc/testsuite/gcc.dg/torture/pr42667.c b/gcc/testsuite/gcc.dg/torture/pr42667.c
new file mode 100644 (file)
index 0000000..eac8001
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+extern int strlen(const char *);
+void WriteTextDots(int len);
+
+void OnDisplay(char * string)
+{
+  if (!string)
+    string = "(none)";
+  WriteTextDots(strlen(string));
+}
+