Patchwork [committed] Fix fallout from snprintf folding patch (PR tree-optimization/48129)

login
register
mail settings
Submitter Jakub Jelinek
Date March 15, 2011, 11:31 a.m.
Message ID <20110315113153.GA30899@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/86949/
State New
Headers show

Comments

Jakub Jelinek - March 15, 2011, 11:31 a.m.
Hi!

On some targets implicit_built_in_decls[BUILT_IN_SNPRINTF] is NULL,
but as we want only the return type of the snprintf function
and fold_builtin_snprintf in that case is only used when
__builtin_* variant is used explicitly, using built_in_decls
is better and avoids the ICE.

Bootstrapped/regtested on x86_64-linux and i686-linux, tested
on the testcase with cross to cris-elf, committed to trunk
as obvious.

2011-03-15  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/48129
	* builtins.c (fold_builtin_snprintf): Convert to type of
	built_in_decls[BUILT_IN_SNPRINTF] retval instead of
	implicit_built_in_decls[BUILT_IN_SNPRINTF] retval.


	Jakub

Patch

--- gcc/builtins.c.jj	2011-03-15 09:47:12.000000000 +0100
+++ gcc/builtins.c	2011-03-15 10:05:25.000000000 +0100
@@ -12038,9 +12038,8 @@  fold_builtin_snprintf (location_t loc, t
 
   if (call && retval)
     {
-      retval = fold_convert_loc
-	(loc, TREE_TYPE (TREE_TYPE (implicit_built_in_decls[BUILT_IN_SNPRINTF])),
-	 retval);
+      tree fn = built_in_decls[BUILT_IN_SNPRINTF];
+      retval = fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fn)), retval);
       return build2 (COMPOUND_EXPR, TREE_TYPE (retval), call, retval);
     }
   else