re PR tree-optimization/89566 (ICE on compilable C++ code: in gimple_call_arg, at gimple.h:3166)

PR tree-optimization/89566
	* gimple-ssa-sprintf.c (sprintf_dom_walker::handle_gimple_call):
	Set info.fncode to BUILT_IN_NONE if gimple_call_builtin_p failed.
	Punt if get_user_idx_format succeeds, but idx_format argument is
	not provided or doesn't have pointer type, or if idx_args is above
	number of provided arguments.

	* c-c++-common/pr89566.c: New test.

From-SVN: r269384
This commit is contained in:
Jakub Jelinek 2019-03-05 09:43:16 +01:00 committed by Jakub Jelinek
parent da7382442e
commit d6f7829a1f
4 changed files with 38 additions and 4 deletions

View File

@ -1,3 +1,12 @@
2019-03-05 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/89566
* gimple-ssa-sprintf.c (sprintf_dom_walker::handle_gimple_call):
Set info.fncode to BUILT_IN_NONE if gimple_call_builtin_p failed.
Punt if get_user_idx_format succeeds, but idx_format argument is
not provided or doesn't have pointer type, or if idx_args is above
number of provided arguments.
2019-03-04 Wilco Dijkstra <wdijkstr@arm.com>
PR tree-optimization/89437

View File

@ -3858,16 +3858,21 @@ sprintf_dom_walker::handle_gimple_call (gimple_stmt_iterator *gsi)
if (!info.func)
return false;
info.fncode = DECL_FUNCTION_CODE (info.func);
/* Format string argument number (valid for all functions). */
unsigned idx_format = UINT_MAX;
if (!gimple_call_builtin_p (info.callstmt, BUILT_IN_NORMAL))
if (gimple_call_builtin_p (info.callstmt, BUILT_IN_NORMAL))
info.fncode = DECL_FUNCTION_CODE (info.func);
else
{
unsigned idx_args;
idx_format = get_user_idx_format (info.func, &idx_args);
if (idx_format == UINT_MAX)
if (idx_format == UINT_MAX
|| idx_format >= gimple_call_num_args (info.callstmt)
|| idx_args > gimple_call_num_args (info.callstmt)
|| !POINTER_TYPE_P (TREE_TYPE (gimple_call_arg (info.callstmt,
idx_format))))
return false;
info.fncode = BUILT_IN_NONE;
info.argidx = idx_args;
}

View File

@ -1,3 +1,8 @@
2019-03-05 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/89566
* c-c++-common/pr89566.c: New test.
2019-03-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84605

View File

@ -0,0 +1,15 @@
/* PR tree-optimization/89566 */
/* { dg-do compile } */
typedef struct FILE { int i; } FILE;
#ifdef __cplusplus
extern "C"
#endif
int fprintf (FILE *, const char *, ...);
int
main ()
{
((void (*)()) fprintf) (); // { dg-warning "function called through a non-compatible type" "" { target c } }
return 0;
}