]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/c-family/ChangeLog
PR c/77531 - __attribute__((alloc_size(1,2))) could also warn on multiplication overflow
authormsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Dec 2016 23:50:40 +0000 (23:50 +0000)
committermsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Dec 2016 23:50:40 +0000 (23:50 +0000)
commit370e45b9887b6603911bbe1776c556d2404455bf
tree1265e2a8ec25f7020ef6c9eb300baef80c2e2afa
parent479d1189cd705a30e3a247c4170794b29c3adc42
PR c/77531 - __attribute__((alloc_size(1,2))) could also warn on multiplication overflow
PR c/78284 - warn on malloc with very large arguments

gcc/c-family/ChangeLog:

PR c/78284
* c.opt (-Walloc-zero, -Walloc-size-larger-than): New options.

gcc/ChangeLog:

PR c/78284
* builtin-attrs.def (ATTR_ALLOC_SIZE, ATTR_RETURNS_NONNULL): New
identifier tree nodes.
(ATTR_ALLOCA_SIZE_1_NOTHROW_LEAF_LIST): New attribute list.
(ATTR_MALLOC_SIZE_1_NOTHROW_LIST): Same.
(ATTR_MALLOC_SIZE_1_NOTHROW_LEAF_LIST): Same.
(ATTR_MALLOC_SIZE_1_2_NOTHROW_LEAF_LIST): Same.
(ATTR_ALLOC_SIZE_2_NOTHROW_LEAF_LIST): Same.
* builtins.c (expand_builtin_alloca): Call
maybe_warn_alloc_args_overflow.
* builtins.def (aligned_alloc, calloc, malloc, realloc):
Add attribute alloc_size.
(alloca): Add attribute alloc_size and returns_nonnull.
* calls.h (maybe_warn_alloc_args_overflow): Declare.
* calls.c (alloc_max_size, operand_signed_p): New functions.
(maybe_warn_alloc_args_overflow): Define.
(initialize_argument_information): Diagnose overflow in functions
declared with attaribute alloc_size.
* doc/invoke.texi (Warning Options): Document -Walloc-zero and
-Walloc-size-larger-than.

gcc/testsuite/ChangeLog:

PR c/78284
* gcc.dg/attr-alloc_size-3.c: New test.
* gcc.dg/attr-alloc_size-4.c: New test.
* gcc.dg/attr-alloc_size-5.c: New test.
* gcc.dg/attr-alloc_size-6.c: New test.
* gcc.dg/attr-alloc_size-7.c: New test.
* gcc.dg/attr-alloc_size-8.c: New test.
* gcc.dg/attr-alloc_size-9.c: New test.
* gcc/testsuite/gcc.dg/errno-1.c: Adjust.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243470 138bc75d-0d04-0410-961f-82ee72b054a4
16 files changed:
gcc/ChangeLog
gcc/builtins.c
gcc/c-family/ChangeLog
gcc/c-family/c.opt
gcc/calls.c
gcc/calls.h
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/attr-alloc_size-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-alloc_size-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-alloc_size-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-alloc_size-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-alloc_size-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-alloc_size-8.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-alloc_size-9.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/errno-1.c