This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [4.4 PATCH] Backport PR middle-end/42667 fix


On Thu, 14 Jan 2010, Jakub Jelinek wrote:

> Hi!
> 
> This fix seems to be safe and has been bootstrapped/regtested on
> {i686,x86_64}-linux on the 4.4 branch.  Ok for branch?

Ok.  There's no approval needed for backport of regression fixes
AFAIK.

Thanks,
Richard.

> 2010-01-14  Jakub Jelinek  <jakub@redhat.com>
> 
> 	Backport from mainline
> 	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.
> 
> --- gcc/builtins.c	(revision 155790)
> +++ gcc/builtins.c	(revision 155791)
> @@ -151,7 +151,7 @@ static rtx expand_builtin_expect (tree, 
>  static tree fold_builtin_constant_p (tree);
>  static tree fold_builtin_expect (tree, tree);
>  static tree fold_builtin_classify_type (tree);
> -static tree fold_builtin_strlen (tree);
> +static tree fold_builtin_strlen (tree, tree);
>  static tree fold_builtin_inf (tree, int);
>  static tree fold_builtin_nan (tree, tree, int);
>  static tree rewrite_call_expr (tree, int, tree, int, ...);
> @@ -7359,7 +7359,7 @@ fold_builtin_classify_type (tree arg)
>  /* Fold a call to __builtin_strlen with argument ARG.  */
>  
>  static tree
> -fold_builtin_strlen (tree arg)
> +fold_builtin_strlen (tree type, tree arg)
>  {
>    if (!validate_arg (arg, POINTER_TYPE))
>      return NULL_TREE;
> @@ -7368,12 +7368,7 @@ fold_builtin_strlen (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 (size_type_node, len);
> -	  return len;
> -	}
> +	return fold_convert (type, len);
>  
>        return NULL_TREE;
>      }
> @@ -10134,7 +10129,7 @@ fold_builtin_1 (tree fndecl, tree arg0, 
>        return fold_builtin_classify_type (arg0);
>  
>      case BUILT_IN_STRLEN:
> -      return fold_builtin_strlen (arg0);
> +      return fold_builtin_strlen (type, arg0);
>  
>      CASE_FLT_FN (BUILT_IN_FABS):
>        return fold_builtin_fabs (arg0, type);
> --- gcc/testsuite/gcc.dg/torture/pr42667.c	(revision 0)
> +++ gcc/testsuite/gcc.dg/torture/pr42667.c	(revision 155791)
> @@ -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));
> +}
> +
> 
> 	Jakub
> 
> 

-- 
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]