diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-03-03 13:05:53 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-03-03 13:05:53 +0000 |
commit | b430e8d98964bc1866199ac6eb5faecdbd963be1 (patch) | |
tree | adb9abf659e3d9d8949be2fad8b9306ded1d415d /gcc/builtins.c | |
parent | bc79a76b630400ddbd6dd00aab74914e58349eb3 (diff) | |
download | gcc-b430e8d98964bc1866199ac6eb5faecdbd963be1.tar.gz |
2009-03-03 Richard Guenther <rguenther@suse.de>
PR middle-end/39272
* tree.c (tree_nonartificial_location): New function.
* tree.h (tree_nonartificial_location): Declare.
* builtins.c (expand_builtin_memory_chk): Provide location
of the call location for artificial function pieces.
(maybe_emit_chk_warning): Likewise.
(maybe_emit_sprintf_chk_warning): Likewise.
(maybe_emit_free_warning): Likewise.
* expr.c (expand_expr_real_1): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144573 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 55639cde728..cc9d93e2311 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -11965,8 +11965,9 @@ expand_builtin_memory_chk (tree exp, rtx target, enum machine_mode mode, if (! integer_all_onesp (size) && tree_int_cst_lt (size, len)) { - warning (0, "%Kcall to %D will always overflow destination buffer", - exp, get_callee_fndecl (exp)); + warning_at (tree_nonartificial_location (exp), + 0, "%Kcall to %D will always overflow destination buffer", + exp, get_callee_fndecl (exp)); return NULL_RTX; } @@ -12073,6 +12074,7 @@ maybe_emit_chk_warning (tree exp, enum built_in_function fcode) { int is_strlen = 0; tree len, size; + location_t loc = tree_nonartificial_location (exp); switch (fcode) { @@ -12119,8 +12121,8 @@ maybe_emit_chk_warning (tree exp, enum built_in_function fcode) src = c_strlen (src, 1); if (! src || ! host_integerp (src, 1)) { - warning (0, "%Kcall to %D might overflow destination buffer", - exp, get_callee_fndecl (exp)); + warning_at (loc, 0, "%Kcall to %D might overflow destination buffer", + exp, get_callee_fndecl (exp)); return; } else if (tree_int_cst_lt (src, size)) @@ -12129,8 +12131,8 @@ maybe_emit_chk_warning (tree exp, enum built_in_function fcode) else if (! host_integerp (len, 1) || ! tree_int_cst_lt (size, len)) return; - warning (0, "%Kcall to %D will always overflow destination buffer", - exp, get_callee_fndecl (exp)); + warning_at (loc, 0, "%Kcall to %D will always overflow destination buffer", + exp, get_callee_fndecl (exp)); } /* Emit warning if a buffer overflow is detected at compile time @@ -12187,10 +12189,9 @@ maybe_emit_sprintf_chk_warning (tree exp, enum built_in_function fcode) return; if (! tree_int_cst_lt (len, size)) - { - warning (0, "%Kcall to %D will always overflow destination buffer", - exp, get_callee_fndecl (exp)); - } + warning_at (tree_nonartificial_location (exp), + 0, "%Kcall to %D will always overflow destination buffer", + exp, get_callee_fndecl (exp)); } /* Emit warning if a free is called with address of a variable. */ @@ -12209,9 +12210,11 @@ maybe_emit_free_warning (tree exp) return; if (SSA_VAR_P (arg)) - warning (0, "%Kattempt to free a non-heap object %qD", exp, arg); + warning_at (tree_nonartificial_location (exp), + 0, "%Kattempt to free a non-heap object %qD", exp, arg); else - warning (0, "%Kattempt to free a non-heap object", exp); + warning_at (tree_nonartificial_location (exp), + 0, "%Kattempt to free a non-heap object", exp); } /* Fold a call to __builtin_object_size with arguments PTR and OST, |