summaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authormeheff <meheff@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-23 18:06:42 +0000
committermeheff <meheff@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-23 18:06:42 +0000
commitf74ea1c2a9293d0fc474e429b2728f348c53a8e9 (patch)
tree617e016549617abef28a5f2414f2c7309caae53b /gcc/builtins.c
parent2339767f2e6796590081d9a2ab2de4dca1ed2a68 (diff)
downloadgcc-f74ea1c2a9293d0fc474e429b2728f348c53a8e9.tar.gz
2011-08-23 Mark Heffernan <meheff@google.com>
PR middle-end/38509 * common.opt (Wfree-nonheap-object): New option. * doc/invoke.texi (Warning options): Document -Wfree-nonheap-object. * builtins.c (maybe_emit_free_warning): Add OPT_Wfree_nonheap_object to warning. (expand_builtin): Make warning conditional. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178004 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 1f263073fe5..b79ce6f4a74 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -6096,7 +6096,8 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
break;
case BUILT_IN_FREE:
- maybe_emit_free_warning (exp);
+ if (warn_free_nonheap_object)
+ maybe_emit_free_warning (exp);
break;
default: /* just do library call, if unknown builtin */
@@ -11915,11 +11916,11 @@ maybe_emit_free_warning (tree exp)
return;
if (SSA_VAR_P (arg))
- warning_at (tree_nonartificial_location (exp),
- 0, "%Kattempt to free a non-heap object %qD", exp, arg);
+ warning_at (tree_nonartificial_location (exp), OPT_Wfree_nonheap_object,
+ "%Kattempt to free a non-heap object %qD", exp, arg);
else
- warning_at (tree_nonartificial_location (exp),
- 0, "%Kattempt to free a non-heap object", exp);
+ warning_at (tree_nonartificial_location (exp), OPT_Wfree_nonheap_object,
+ "%Kattempt to free a non-heap object", exp);
}
/* Fold a call to __builtin_object_size with arguments PTR and OST,