Commit 8a45b051 by Martin Sebor Committed by Martin Sebor

PR tree-optimization/86650 - -Warray-bounds missing inlining context

gcc/c/ChangeLog:

	PR tree-optimization/86650
	* c-objc-common.c (c_tree_printer): Move usage of EXPR_LOCATION (t)
	and TREE_BLOCK (t) from within percent_K_format	to this callsite.

gcc/c-family/ChangeLog:

	PR tree-optimization/86650
	* c-family/c-format.c (gcc_tdiag_char_table): Update comment for "%G".
	(gcc_cdiag_char_table, gcc_cxxdiag_char_table): Same.
 	(init_dynamic_diag_info): Update from "gcall *" to "gimple *".
 	* c-format.h (T89_G): Update to be "gimple *" rather than
 	"gcall *".
	(local_gcall_ptr_node): Rename...
 	(local_gimple_ptr_node): ...to this.

gcc/cp/ChangeLog:

	PR tree-optimization/86650
	* error.c (cp_printer): Move usage of EXPR_LOCATION (t) and
	TREE_BLOCK (t) from within percent_K_format to this callsite.

gcc/ChangeLog:

	PR tree-optimization/86650
	* gimple-pretty-print.c (percent_G_format): Accept a "gimple *"
	rather than a "gcall *".  Directly pass the data of interest
 	to percent_K_format, rather than building a temporary CALL_EXPR
 	to hold it.
	* gimple-fold.c (gimple_fold_builtin_strncpy): Adjust.
	(gimple_fold_builtin_strncat): Adjust.
	* gimple-ssa-warn-restrict.h (check_bounds_or_overlap): Replace
	gcall* argument with gimple*.
	* gimple-ssa-warn-restrict.c (check_call): Same.
	(wrestrict_dom_walker::before_dom_children): Same.
	(builtin_access::builtin_access): Same.
	(check_bounds_or_overlap): Same
	(maybe_diag_overlap): Same.
	(maybe_diag_offset_bounds): Same.
	* tree-diagnostic.c (default_tree_printer): Move usage of
	EXPR_LOCATION (t) and TREE_BLOCK (t) from within percent_K_format
	to this callsite.
	* tree-pretty-print.c (percent_K_format): Add argument.
	* tree-pretty-print.h: Add argument.
	* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Adjust.
	* tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Adjust.
	(maybe_diag_stxncpy_trunc): Same.
	(handle_builtin_stxncpy): Same.
	(handle_builtin_strcat): Same.

gcc/testsuite/ChangeLog:

	PR tree-optimization/86650
	* gcc.dg/format/gcc_diag-10.c: Adjust.

From-SVN: r263239
parent ca9a1314
2018-08-01 Martin Sebor <msebor@redhat.com>
PR tree-optimization/86650
* gimple-pretty-print.c (percent_G_format): Accept a "gimple *"
rather than a "gcall *". Directly pass the data of interest
to percent_K_format, rather than building a temporary CALL_EXPR
to hold it.
* gimple-fold.c (gimple_fold_builtin_strncpy): Adjust.
(gimple_fold_builtin_strncat): Adjust.
* gimple-ssa-warn-restrict.h (check_bounds_or_overlap): Replace
gcall* argument with gimple*.
* gimple-ssa-warn-restrict.c (check_call): Same.
(wrestrict_dom_walker::before_dom_children): Same.
(builtin_access::builtin_access): Same.
(check_bounds_or_overlap): Same
(maybe_diag_overlap): Same.
(maybe_diag_offset_bounds): Same.
* tree-diagnostic.c (default_tree_printer): Move usage of
EXPR_LOCATION (t) and TREE_BLOCK (t) from within percent_K_format
to this callsite.
* tree-pretty-print.c (percent_K_format): Add argument.
* tree-pretty-print.h: Add argument.
* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Adjust.
* tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Adjust.
(maybe_diag_stxncpy_trunc): Same.
(handle_builtin_stxncpy): Same.
(handle_builtin_strcat): Same.
2018-08-01 Richard Sandiford <richard.sandiford@arm.com> 2018-08-01 Richard Sandiford <richard.sandiford@arm.com>
* match.pd: Optimise pointer range checks. * match.pd: Optimise pointer range checks.
......
2018-08-01 Martin Sebor <msebor@redhat.com>
PR tree-optimization/86650
* c-family/c-format.c (gcc_tdiag_char_table): Update comment for "%G".
(gcc_cdiag_char_table, gcc_cxxdiag_char_table): Same.
(init_dynamic_diag_info): Update from "gcall *" to "gimple *".
* c-format.h (T89_G): Update to be "gimple *" rather than
"gcall *".
(local_gcall_ptr_node): Rename...
(local_gimple_ptr_node): ...to this.
2018-07-31 David Malcolm <dmalcolm@redhat.com> 2018-07-31 David Malcolm <dmalcolm@redhat.com>
* c-format.c (PP_FORMAT_CHAR_TABLE): New macro, based on existing * c-format.c (PP_FORMAT_CHAR_TABLE): New macro, based on existing
......
...@@ -56,7 +56,7 @@ struct function_format_info ...@@ -56,7 +56,7 @@ struct function_format_info
/* Initialized in init_dynamic_diag_info. */ /* Initialized in init_dynamic_diag_info. */
static GTY(()) tree local_tree_type_node; static GTY(()) tree local_tree_type_node;
static GTY(()) tree local_gcall_ptr_node; static GTY(()) tree local_gimple_ptr_node;
static GTY(()) tree locus; static GTY(()) tree locus;
static bool decode_format_attr (tree, function_format_info *, int); static bool decode_format_attr (tree, function_format_info *, int);
...@@ -719,7 +719,7 @@ static const format_char_info gcc_tdiag_char_table[] = ...@@ -719,7 +719,7 @@ static const format_char_info gcc_tdiag_char_table[] =
{ "E", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "", NULL }, { "E", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "", NULL },
{ "K", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, { "K", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL },
/* G requires a "gcall*" argument at runtime. */ /* G requires a "gimple*" argument at runtime. */
{ "G", 1, STD_C89, { T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, { "G", 1, STD_C89, { T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL },
{ NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
...@@ -737,7 +737,7 @@ static const format_char_info gcc_cdiag_char_table[] = ...@@ -737,7 +737,7 @@ static const format_char_info gcc_cdiag_char_table[] =
{ "E", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "", NULL }, { "E", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "", NULL },
{ "K", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, { "K", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL },
/* G requires a "gcall*" argument at runtime. */ /* G requires a "gimple*" argument at runtime. */
{ "G", 1, STD_C89, { T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, { "G", 1, STD_C89, { T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL },
{ "v", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q#", "", NULL }, { "v", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q#", "", NULL },
...@@ -757,7 +757,7 @@ static const format_char_info gcc_cxxdiag_char_table[] = ...@@ -757,7 +757,7 @@ static const format_char_info gcc_cxxdiag_char_table[] =
{ "E", 1,STD_C89,{ T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+#", "", NULL }, { "E", 1,STD_C89,{ T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+#", "", NULL },
{ "K", 1, STD_C89,{ T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, { "K", 1, STD_C89,{ T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL },
/* G requires a "gcall*" argument at runtime. */ /* G requires a "gimple*" argument at runtime. */
{ "G", 1, STD_C89,{ T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, { "G", 1, STD_C89,{ T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL },
/* These accept either an 'int' or an 'enum tree_code' (which is handled as an 'int'.) */ /* These accept either an 'int' or an 'enum tree_code' (which is handled as an 'int'.) */
...@@ -3838,27 +3838,27 @@ init_dynamic_diag_info (void) ...@@ -3838,27 +3838,27 @@ init_dynamic_diag_info (void)
local_tree_type_node = void_type_node; local_tree_type_node = void_type_node;
} }
/* Similar to the above but for gcall*. */ /* Similar to the above but for gimple*. */
if (!local_gcall_ptr_node if (!local_gimple_ptr_node
|| local_gcall_ptr_node == void_type_node) || local_gimple_ptr_node == void_type_node)
{ {
if ((local_gcall_ptr_node = maybe_get_identifier ("gcall"))) if ((local_gimple_ptr_node = maybe_get_identifier ("gimple")))
{ {
local_gcall_ptr_node local_gimple_ptr_node
= identifier_global_value (local_gcall_ptr_node); = identifier_global_value (local_gimple_ptr_node);
if (local_gcall_ptr_node) if (local_gimple_ptr_node)
{ {
if (TREE_CODE (local_gcall_ptr_node) != TYPE_DECL) if (TREE_CODE (local_gimple_ptr_node) != TYPE_DECL)
{ {
error ("%<gcall%> is not defined as a type"); error ("%<gimple%> is not defined as a type");
local_gcall_ptr_node = 0; local_gimple_ptr_node = 0;
} }
else else
local_gcall_ptr_node = TREE_TYPE (local_gcall_ptr_node); local_gimple_ptr_node = TREE_TYPE (local_gimple_ptr_node);
} }
} }
else else
local_gcall_ptr_node = void_type_node; local_gimple_ptr_node = void_type_node;
} }
static tree hwi; static tree hwi;
......
...@@ -298,7 +298,7 @@ struct format_kind_info ...@@ -298,7 +298,7 @@ struct format_kind_info
#define T_UC &unsigned_char_type_node #define T_UC &unsigned_char_type_node
#define T99_UC { STD_C99, NULL, T_UC } #define T99_UC { STD_C99, NULL, T_UC }
#define T_V &void_type_node #define T_V &void_type_node
#define T89_G { STD_C89, NULL, &local_gcall_ptr_node } #define T89_G { STD_C89, NULL, &local_gimple_ptr_node }
#define T89_T { STD_C89, NULL, &local_tree_type_node } #define T89_T { STD_C89, NULL, &local_tree_type_node }
#define T89_V { STD_C89, NULL, T_V } #define T89_V { STD_C89, NULL, T_V }
#define T_W &wchar_type_node #define T_W &wchar_type_node
......
2018-08-01 Martin Sebor <msebor@redhat.com>
PR tree-optimization/86650
* c-objc-common.c (c_tree_printer): Move usage of EXPR_LOCATION (t)
and TREE_BLOCK (t) from within percent_K_format to this callsite.
2018-08-01 Jakub Jelinek <jakub@redhat.com> 2018-08-01 Jakub Jelinek <jakub@redhat.com>
PR c/85704 PR c/85704
......
...@@ -67,7 +67,7 @@ c_objc_common_init (void) ...@@ -67,7 +67,7 @@ c_objc_common_init (void)
%D: a general decl, %D: a general decl,
%E: an identifier or expression, %E: an identifier or expression,
%F: a function declaration, %F: a function declaration,
%G: a Gimple call statement, %G: a Gimple statement,
%K: a CALL_EXPR, %K: a CALL_EXPR,
%T: a type. %T: a type.
%V: a list of type qualifiers from a tree. %V: a list of type qualifiers from a tree.
...@@ -99,7 +99,7 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec, ...@@ -99,7 +99,7 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
if (*spec == 'K') if (*spec == 'K')
{ {
t = va_arg (*text->args_ptr, tree); t = va_arg (*text->args_ptr, tree);
percent_K_format (text, t); percent_K_format (text, EXPR_LOCATION (t), TREE_BLOCK (t));
return true; return true;
} }
......
2018-08-01 Martin Sebor <msebor@redhat.com>
PR tree-optimization/86650
* error.c (cp_printer): Move usage of EXPR_LOCATION (t) and
TREE_BLOCK (t) from within percent_K_format to this callsite.
2018-08-01 Paolo Carlini <paolo.carlini@oracle.com> 2018-08-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/86661 PR c++/86661
......
...@@ -4091,7 +4091,7 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec, ...@@ -4091,7 +4091,7 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec,
return true; return true;
case 'K': case 'K':
t = va_arg (*text->args_ptr, tree); t = va_arg (*text->args_ptr, tree);
percent_K_format (text, t); percent_K_format (text, EXPR_LOCATION (t), TREE_BLOCK (t));
return true; return true;
case 'L': result = language_to_string (next_lang); break; case 'L': result = language_to_string (next_lang); break;
case 'O': result = op_to_string (false, next_tcode); break; case 'O': result = op_to_string (false, next_tcode); break;
......
...@@ -1657,7 +1657,6 @@ gimple_fold_builtin_strncpy (gimple_stmt_iterator *gsi, ...@@ -1657,7 +1657,6 @@ gimple_fold_builtin_strncpy (gimple_stmt_iterator *gsi,
if (!nonstring) if (!nonstring)
{ {
tree fndecl = gimple_call_fndecl (stmt); tree fndecl = gimple_call_fndecl (stmt);
gcall *call = as_a <gcall *> (stmt);
/* Warn about the lack of nul termination: the result is not /* Warn about the lack of nul termination: the result is not
a (nul-terminated) string. */ a (nul-terminated) string. */
...@@ -1666,11 +1665,11 @@ gimple_fold_builtin_strncpy (gimple_stmt_iterator *gsi, ...@@ -1666,11 +1665,11 @@ gimple_fold_builtin_strncpy (gimple_stmt_iterator *gsi,
warning_at (loc, OPT_Wstringop_truncation, warning_at (loc, OPT_Wstringop_truncation,
"%G%qD destination unchanged after copying no bytes " "%G%qD destination unchanged after copying no bytes "
"from a string of length %E", "from a string of length %E",
call, fndecl, slen); stmt, fndecl, slen);
else else
warning_at (loc, OPT_Wstringop_truncation, warning_at (loc, OPT_Wstringop_truncation,
"%G%qD destination unchanged after copying no bytes", "%G%qD destination unchanged after copying no bytes",
call, fndecl); stmt, fndecl);
} }
replace_call_with_value (gsi, dest); replace_call_with_value (gsi, dest);
...@@ -1991,7 +1990,7 @@ gimple_fold_builtin_strcat_chk (gimple_stmt_iterator *gsi) ...@@ -1991,7 +1990,7 @@ gimple_fold_builtin_strcat_chk (gimple_stmt_iterator *gsi)
static bool static bool
gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi) gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi)
{ {
gcall *stmt = as_a <gcall *> (gsi_stmt (*gsi)); gimple *stmt = gsi_stmt (*gsi);
tree dst = gimple_call_arg (stmt, 0); tree dst = gimple_call_arg (stmt, 0);
tree src = gimple_call_arg (stmt, 1); tree src = gimple_call_arg (stmt, 1);
tree len = gimple_call_arg (stmt, 2); tree len = gimple_call_arg (stmt, 2);
......
...@@ -2887,20 +2887,13 @@ gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb) ...@@ -2887,20 +2887,13 @@ gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
/* Handle the %G format for TEXT. Same as %K in handle_K_format in /* Handle the %G format for TEXT. Same as %K in handle_K_format in
tree-pretty-print.c but with a Gimple call statement as an argument. */ tree-pretty-print.c but with a Gimple statement as an argument. */
void void
percent_G_format (text_info *text) percent_G_format (text_info *text)
{ {
gcall *stmt = va_arg (*text->args_ptr, gcall*); gimple *stmt = va_arg (*text->args_ptr, gimple*);
/* Build a call expression from the Gimple call statement and tree block = gimple_block (stmt);
pass it to the K formatter that knows how to format it. */ percent_K_format (text, gimple_location (stmt), block);
tree exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
TREE_TYPE (exp) = gimple_call_return_type (stmt);
CALL_EXPR_STATIC_CHAIN (exp) = gimple_call_chain (stmt);
SET_EXPR_LOCATION (exp, gimple_location (stmt));
percent_K_format (text, exp);
} }
...@@ -88,7 +88,7 @@ class wrestrict_dom_walker : public dom_walker ...@@ -88,7 +88,7 @@ class wrestrict_dom_walker : public dom_walker
bool handle_gimple_call (gimple_stmt_iterator *); bool handle_gimple_call (gimple_stmt_iterator *);
private: private:
void check_call (gcall *); void check_call (gimple *);
}; };
edge edge
...@@ -102,8 +102,7 @@ wrestrict_dom_walker::before_dom_children (basic_block bb) ...@@ -102,8 +102,7 @@ wrestrict_dom_walker::before_dom_children (basic_block bb)
if (!is_gimple_call (stmt)) if (!is_gimple_call (stmt))
continue; continue;
if (gcall *call = as_a <gcall *> (stmt)) check_call (stmt);
check_call (call);
} }
return NULL; return NULL;
...@@ -192,7 +191,7 @@ class builtin_access ...@@ -192,7 +191,7 @@ class builtin_access
return detect_overlap != &builtin_access::generic_overlap; return detect_overlap != &builtin_access::generic_overlap;
} }
builtin_access (gcall *, builtin_memref &, builtin_memref &); builtin_access (gimple *, builtin_memref &, builtin_memref &);
/* Entry point to determine overlap. */ /* Entry point to determine overlap. */
bool overlap (); bool overlap ();
...@@ -563,7 +562,7 @@ builtin_memref::offset_out_of_bounds (int strict, offset_int ooboff[2]) const ...@@ -563,7 +562,7 @@ builtin_memref::offset_out_of_bounds (int strict, offset_int ooboff[2]) const
/* Create an association between the memory references DST and SRC /* Create an association between the memory references DST and SRC
for access by a call EXPR to a memory or string built-in funtion. */ for access by a call EXPR to a memory or string built-in funtion. */
builtin_access::builtin_access (gcall *call, builtin_memref &dst, builtin_access::builtin_access (gimple *call, builtin_memref &dst,
builtin_memref &src) builtin_memref &src)
: dstref (&dst), srcref (&src), sizrange (), ovloff (), ovlsiz (), : dstref (&dst), srcref (&src), sizrange (), ovloff (), ovlsiz (),
dstoff (), srcoff (), dstsiz (), srcsiz () dstoff (), srcoff (), dstsiz (), srcsiz ()
...@@ -1324,7 +1323,7 @@ builtin_access::overlap () ...@@ -1324,7 +1323,7 @@ builtin_access::overlap ()
Return true when one has been detected, false otherwise. */ Return true when one has been detected, false otherwise. */
static bool static bool
maybe_diag_overlap (location_t loc, gcall *call, builtin_access &acs) maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs)
{ {
if (!acs.overlap ()) if (!acs.overlap ())
return false; return false;
...@@ -1577,7 +1576,7 @@ maybe_diag_overlap (location_t loc, gcall *call, builtin_access &acs) ...@@ -1577,7 +1576,7 @@ maybe_diag_overlap (location_t loc, gcall *call, builtin_access &acs)
has been issued. */ has been issued. */
static bool static bool
maybe_diag_offset_bounds (location_t loc, gcall *call, tree func, int strict, maybe_diag_offset_bounds (location_t loc, gimple *call, tree func, int strict,
tree expr, const builtin_memref &ref) tree expr, const builtin_memref &ref)
{ {
if (!warn_array_bounds) if (!warn_array_bounds)
...@@ -1722,7 +1721,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *call, tree func, int strict, ...@@ -1722,7 +1721,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *call, tree func, int strict,
if/when appropriate. */ if/when appropriate. */
void void
wrestrict_dom_walker::check_call (gcall *call) wrestrict_dom_walker::check_call (gimple *call)
{ {
/* Avoid checking the call if it has already been diagnosed for /* Avoid checking the call if it has already been diagnosed for
some reason. */ some reason. */
...@@ -1822,7 +1821,7 @@ wrestrict_dom_walker::check_call (gcall *call) ...@@ -1822,7 +1821,7 @@ wrestrict_dom_walker::check_call (gcall *call)
detected and diagnosed, true otherwise. */ detected and diagnosed, true otherwise. */
bool bool
check_bounds_or_overlap (gcall *call, tree dst, tree src, tree dstsize, check_bounds_or_overlap (gimple *call, tree dst, tree src, tree dstsize,
tree srcsize, bool bounds_only /* = false */) tree srcsize, bool bounds_only /* = false */)
{ {
location_t loc = gimple_nonartificial_location (call); location_t loc = gimple_nonartificial_location (call);
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#ifndef GIMPLE_SSA_WARN_RESTRICT_H #ifndef GIMPLE_SSA_WARN_RESTRICT_H
extern bool check_bounds_or_overlap (gcall *, tree, tree, tree, tree, extern bool check_bounds_or_overlap (gimple *, tree, tree, tree, tree,
bool = false); bool = false);
#endif /* GIMPLE_SSA_WARN_RESTRICT_H */ #endif /* GIMPLE_SSA_WARN_RESTRICT_H */
2018-08-01 Martin Sebor <msebor@redhat.com>
PR tree-optimization/86650
* gcc.dg/format/gcc_diag-10.c: Adjust.
2018-08-01 Richard Sandiford <richard.sandiford@arm.com> 2018-08-01 Richard Sandiford <richard.sandiford@arm.com>
* gcc.target/aarch64/sve/var_stride_2.c: Update expected form * gcc.target/aarch64/sve/var_stride_2.c: Update expected form
......
...@@ -15,9 +15,9 @@ typedef struct location_s ...@@ -15,9 +15,9 @@ typedef struct location_s
union tree_node; union tree_node;
typedef union tree_node *tree; typedef union tree_node *tree;
/* Define gcall as a dummy type. The typedef must be provided for /* Define gimple as a dummy type. The typedef must be provided for
the C test to find the symbol. */ the C test to find the symbol. */
typedef struct gcall gcall; typedef struct gimple gimple;
#define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2))) #define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2)))
...@@ -26,7 +26,7 @@ void cdiag (const char*, ...) FORMAT (cdiag); ...@@ -26,7 +26,7 @@ void cdiag (const char*, ...) FORMAT (cdiag);
void tdiag (const char*, ...) FORMAT (tdiag); void tdiag (const char*, ...) FORMAT (tdiag);
void cxxdiag (const char*, ...) FORMAT (cxxdiag); void cxxdiag (const char*, ...) FORMAT (cxxdiag);
void test_diag (tree t, gcall *gc) void test_diag (tree t, gimple *gc)
{ {
diag ("%<"); /* { dg-warning "unterminated quoting directive" } */ diag ("%<"); /* { dg-warning "unterminated quoting directive" } */
diag ("%>"); /* { dg-warning "unmatched quoting directive " } */ diag ("%>"); /* { dg-warning "unmatched quoting directive " } */
...@@ -47,7 +47,7 @@ void test_diag (tree t, gcall *gc) ...@@ -47,7 +47,7 @@ void test_diag (tree t, gcall *gc)
diag ("%<%r%R%>", ""); diag ("%<%r%R%>", "");
} }
void test_cdiag (tree t, gcall *gc) void test_cdiag (tree t, gimple *gc)
{ {
cdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */ cdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */
cdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */ cdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */
...@@ -87,7 +87,7 @@ void test_cdiag (tree t, gcall *gc) ...@@ -87,7 +87,7 @@ void test_cdiag (tree t, gcall *gc)
cdiag ("%<%qT%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */ cdiag ("%<%qT%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
} }
void test_tdiag (tree t, gcall *gc) void test_tdiag (tree t, gimple *gc)
{ {
tdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */ tdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */
tdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */ tdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */
...@@ -124,7 +124,7 @@ void test_tdiag (tree t, gcall *gc) ...@@ -124,7 +124,7 @@ void test_tdiag (tree t, gcall *gc)
tdiag ("%<%qT%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */ tdiag ("%<%qT%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
} }
void test_cxxdiag (tree t, gcall *gc) void test_cxxdiag (tree t, gimple *gc)
{ {
cxxdiag ("%A", t); /* { dg-warning ".A. conversion used unquoted" } */ cxxdiag ("%A", t); /* { dg-warning ".A. conversion used unquoted" } */
cxxdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */ cxxdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
......
...@@ -282,7 +282,7 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec, ...@@ -282,7 +282,7 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
case 'K': case 'K':
t = va_arg (*text->args_ptr, tree); t = va_arg (*text->args_ptr, tree);
percent_K_format (text, t); percent_K_format (text, EXPR_LOCATION (t), TREE_BLOCK (t));
return true; return true;
default: default:
......
...@@ -3980,15 +3980,14 @@ newline_and_indent (pretty_printer *pp, int spc) ...@@ -3980,15 +3980,14 @@ newline_and_indent (pretty_printer *pp, int spc)
/* Handle the %K format for TEXT. Separate from default_tree_printer /* Handle the %K format for TEXT. Separate from default_tree_printer
so it can also be used in front ends. so it can also be used in front ends.
Argument is a statement from which EXPR_LOCATION and TREE_BLOCK will The location LOC and BLOCK are expected to be extracted by the caller
be recorded. */ from the %K argument arg via EXPR_LOCATION(arg) and TREE_BLOCK(arg). */
void void
percent_K_format (text_info *text, tree t) percent_K_format (text_info *text, location_t loc, tree block)
{ {
text->set_location (0, EXPR_LOCATION (t), true); text->set_location (0, loc, true);
gcc_assert (pp_ti_abstract_origin (text) != NULL); gcc_assert (pp_ti_abstract_origin (text) != NULL);
tree block = TREE_BLOCK (t);
*pp_ti_abstract_origin (text) = NULL; *pp_ti_abstract_origin (text) = NULL;
if (in_lto_p) if (in_lto_p)
......
...@@ -45,7 +45,7 @@ extern int op_code_prio (enum tree_code); ...@@ -45,7 +45,7 @@ extern int op_code_prio (enum tree_code);
extern int op_prio (const_tree); extern int op_prio (const_tree);
extern const char *op_symbol_code (enum tree_code); extern const char *op_symbol_code (enum tree_code);
extern void print_call_name (pretty_printer *, tree, dump_flags_t); extern void print_call_name (pretty_printer *, tree, dump_flags_t);
extern void percent_K_format (text_info *, tree); extern void percent_K_format (text_info *, location_t, tree);
extern void pp_tree_identifier (pretty_printer *, tree); extern void pp_tree_identifier (pretty_printer *, tree);
extern void dump_function_header (FILE *, tree, dump_flags_t); extern void dump_function_header (FILE *, tree, dump_flags_t);
extern void pp_double_int (pretty_printer *pp, double_int d, bool uns); extern void pp_double_int (pretty_printer *pp, double_int d, bool uns);
......
...@@ -3456,7 +3456,7 @@ pass_post_ipa_warn::execute (function *fun) ...@@ -3456,7 +3456,7 @@ pass_post_ipa_warn::execute (function *fun)
location_t loc = gimple_location (stmt); location_t loc = gimple_location (stmt);
if (warning_at (loc, OPT_Wnonnull, if (warning_at (loc, OPT_Wnonnull,
"%Gargument %u null where non-null " "%Gargument %u null where non-null "
"expected", as_a <gcall *>(stmt), i + 1)) "expected", stmt, i + 1))
{ {
tree fndecl = gimple_call_fndecl (stmt); tree fndecl = gimple_call_fndecl (stmt);
if (fndecl && DECL_IS_BUILTIN (fndecl)) if (fndecl && DECL_IS_BUILTIN (fndecl))
......
...@@ -1627,8 +1627,7 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) ...@@ -1627,8 +1627,7 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi)
tree type = TREE_TYPE (oldlen); tree type = TREE_TYPE (oldlen);
oldlen = fold_build2 (PLUS_EXPR, type, oldlen, oldlen = fold_build2 (PLUS_EXPR, type, oldlen,
build_int_cst (type, 1)); build_int_cst (type, 1));
check_bounds_or_overlap (as_a <gcall *>(stmt), olddsi->ptr, src, check_bounds_or_overlap (stmt, olddsi->ptr, src, oldlen, NULL_TREE);
oldlen, NULL_TREE);
} }
return; return;
...@@ -1715,8 +1714,7 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) ...@@ -1715,8 +1714,7 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi)
if (const strinfo *chksi = olddsi ? olddsi : dsi) if (const strinfo *chksi = olddsi ? olddsi : dsi)
if (si if (si
&& !check_bounds_or_overlap (as_a <gcall *>(stmt), chksi->ptr, si->ptr, && !check_bounds_or_overlap (stmt, chksi->ptr, si->ptr, NULL_TREE, len))
NULL_TREE, len))
{ {
gimple_set_no_warning (stmt, true); gimple_set_no_warning (stmt, true);
set_no_warning = true; set_no_warning = true;
...@@ -2031,8 +2029,6 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) ...@@ -2031,8 +2029,6 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
lenrange[0] = wi::shwi (0, prec); lenrange[0] = wi::shwi (0, prec);
} }
gcall *call = as_a <gcall *> (stmt);
/* Set to true for strncat whose bound is derived from the length /* Set to true for strncat whose bound is derived from the length
of the destination (the expected usage pattern). */ of the destination (the expected usage pattern). */
bool cat_dstlen_bounded = false; bool cat_dstlen_bounded = false;
...@@ -2048,7 +2044,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) ...@@ -2048,7 +2044,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
"%G%qD output truncated before terminating nul " "%G%qD output truncated before terminating nul "
"copying %E bytes from a string of the same " "copying %E bytes from a string of the same "
"length", "length",
call, func, cnt); stmt, func, cnt);
else if (!cat_dstlen_bounded) else if (!cat_dstlen_bounded)
{ {
if (wi::geu_p (lenrange[0], cntrange[1])) if (wi::geu_p (lenrange[0], cntrange[1]))
...@@ -2062,12 +2058,12 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) ...@@ -2062,12 +2058,12 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
"from a string of length %wu", "from a string of length %wu",
"%G%qD output truncated copying %E bytes " "%G%qD output truncated copying %E bytes "
"from a string of length %wu", "from a string of length %wu",
call, func, cnt, lenrange[0].to_uhwi ()); stmt, func, cnt, lenrange[0].to_uhwi ());
return warning_at (callloc, OPT_Wstringop_truncation, return warning_at (callloc, OPT_Wstringop_truncation,
"%G%qD output truncated copying between %wu " "%G%qD output truncated copying between %wu "
"and %wu bytes from a string of length %wu", "and %wu bytes from a string of length %wu",
call, func, cntrange[0].to_uhwi (), stmt, func, cntrange[0].to_uhwi (),
cntrange[1].to_uhwi (), lenrange[0].to_uhwi ()); cntrange[1].to_uhwi (), lenrange[0].to_uhwi ());
} }
else if (wi::geu_p (lenrange[1], cntrange[1])) else if (wi::geu_p (lenrange[1], cntrange[1]))
...@@ -2081,12 +2077,12 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) ...@@ -2081,12 +2077,12 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
"byte from a string of length %wu", "byte from a string of length %wu",
"%G%qD output may be truncated copying %E " "%G%qD output may be truncated copying %E "
"bytes from a string of length %wu", "bytes from a string of length %wu",
call, func, cnt, lenrange[1].to_uhwi ()); stmt, func, cnt, lenrange[1].to_uhwi ());
return warning_at (callloc, OPT_Wstringop_truncation, return warning_at (callloc, OPT_Wstringop_truncation,
"%G%qD output may be truncated copying between " "%G%qD output may be truncated copying between "
"%wu and %wu bytes from a string of length %wu", "%wu and %wu bytes from a string of length %wu",
call, func, cntrange[0].to_uhwi (), stmt, func, cntrange[0].to_uhwi (),
cntrange[1].to_uhwi (), lenrange[1].to_uhwi ()); cntrange[1].to_uhwi (), lenrange[1].to_uhwi ());
} }
} }
...@@ -2102,7 +2098,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) ...@@ -2102,7 +2098,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
return warning_at (callloc, OPT_Wstringop_truncation, return warning_at (callloc, OPT_Wstringop_truncation,
"%G%qD output may be truncated copying between " "%G%qD output may be truncated copying between "
"%wu and %wu bytes from a string of length %wu", "%wu and %wu bytes from a string of length %wu",
call, func, cntrange[0].to_uhwi (), stmt, func, cntrange[0].to_uhwi (),
cntrange[1].to_uhwi (), lenrange[0].to_uhwi ()); cntrange[1].to_uhwi (), lenrange[0].to_uhwi ());
} }
} }
...@@ -2122,7 +2118,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) ...@@ -2122,7 +2118,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
if (cntrange[0] == cntrange[1]) if (cntrange[0] == cntrange[1])
return warning_at (callloc, OPT_Wstringop_truncation, return warning_at (callloc, OPT_Wstringop_truncation,
"%G%qD specified bound %E equals destination size", "%G%qD specified bound %E equals destination size",
as_a <gcall *> (stmt), func, cnt); stmt, func, cnt);
} }
return false; return false;
...@@ -2180,8 +2176,7 @@ handle_builtin_stxncpy (built_in_function, gimple_stmt_iterator *gsi) ...@@ -2180,8 +2176,7 @@ handle_builtin_stxncpy (built_in_function, gimple_stmt_iterator *gsi)
else else
srcsize = NULL_TREE; srcsize = NULL_TREE;
if (!check_bounds_or_overlap (as_a <gcall *>(stmt), dst, src, if (!check_bounds_or_overlap (stmt, dst, src, dstsize, srcsize))
dstsize, srcsize))
{ {
gimple_set_no_warning (stmt, true); gimple_set_no_warning (stmt, true);
return; return;
...@@ -2222,13 +2217,13 @@ handle_builtin_stxncpy (built_in_function, gimple_stmt_iterator *gsi) ...@@ -2222,13 +2217,13 @@ handle_builtin_stxncpy (built_in_function, gimple_stmt_iterator *gsi)
&& warning_at (callloc, OPT_Wstringop_truncation, && warning_at (callloc, OPT_Wstringop_truncation,
"%G%qD output truncated before terminating nul " "%G%qD output truncated before terminating nul "
"copying as many bytes from a string as its length", "copying as many bytes from a string as its length",
as_a <gcall *>(stmt), func)) stmt, func))
warned = true; warned = true;
else if (silen && is_strlen_related_p (src, silen->ptr)) else if (silen && is_strlen_related_p (src, silen->ptr))
warned = warning_at (callloc, OPT_Wstringop_overflow_, warned = warning_at (callloc, OPT_Wstringop_overflow_,
"%G%qD specified bound depends on the length " "%G%qD specified bound depends on the length "
"of the source argument", "of the source argument",
as_a <gcall *>(stmt), func); stmt, func);
if (warned) if (warned)
{ {
location_t strlenloc = pss->second; location_t strlenloc = pss->second;
...@@ -2479,8 +2474,7 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi) ...@@ -2479,8 +2474,7 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi)
tree sptr = si && si->ptr ? si->ptr : src; tree sptr = si && si->ptr ? si->ptr : src;
if (!check_bounds_or_overlap (as_a <gcall *>(stmt), dst, sptr, if (!check_bounds_or_overlap (stmt, dst, sptr, NULL_TREE, slen))
NULL_TREE, slen))
{ {
gimple_set_no_warning (stmt, true); gimple_set_no_warning (stmt, true);
set_no_warning = true; set_no_warning = true;
...@@ -2590,8 +2584,7 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi) ...@@ -2590,8 +2584,7 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi)
tree sptr = si && si->ptr ? si->ptr : src; tree sptr = si && si->ptr ? si->ptr : src;
if (!check_bounds_or_overlap (as_a <gcall *>(stmt), dst, sptr, if (!check_bounds_or_overlap (stmt, dst, sptr, dstlen, srcsize))
dstlen, srcsize))
{ {
gimple_set_no_warning (stmt, true); gimple_set_no_warning (stmt, true);
set_no_warning = true; set_no_warning = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment