diff options
author | Jakub Jelinek <jakub@redhat.com> | 2012-08-17 09:17:56 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2012-08-17 09:17:56 +0200 |
commit | 1a4049e7c504bedf3f485fd94a26902959a4ce2a (patch) | |
tree | 4109785fceb3bc788cf4f9ee1e8a0fc71649fdfb /gcc/doc | |
parent | 138f5acd18aafd07cd4a034cb8e879dd0621544b (diff) | |
download | gcc-1a4049e7c504bedf3f485fd94a26902959a4ce2a.zip gcc-1a4049e7c504bedf3f485fd94a26902959a4ce2a.tar.gz gcc-1a4049e7c504bedf3f485fd94a26902959a4ce2a.tar.bz2 |
invoke.texi (-Wsizeof-pointer-memaccess): Document.
* doc/invoke.texi (-Wsizeof-pointer-memaccess): Document.
c/
* c-tree.h (c_last_sizeof_arg): Declare.
* c-parser.c (struct c_tree_loc_pair): New type.
(c_parser_expr_list): Add sizeof_arg argument. Fill it in if
non-NULL.
(c_parser_attributes, c_parser_objc_keywordexpr): Adjust callers.
(c_parser_postfix_expression_after_primary): Likewise. Call
sizeof_pointer_memaccess_warning if needed.
(sizeof_ptr_memacc_comptypes): New function.
* c-typeck.c (c_last_sizeof_arg): New global variable.
(c_expr_sizeof_expr, c_expr_sizeof_type): Initialize it.
cp/
* cp-tree.def (SIZEOF_EXPR): Move to c-common.def.
c-family/
* c-common.c (sizeof_pointer_memaccess_warning): New function.
* c.opt (-Wsizeof-pointer-memaccess): Add new option.
* c-opts.c (c_common_handle_option): Enable it for -Wall.
* c-common.h (sizeof_pointer_memaccess_warning): Add prototype.
* c-common.def (SIZEOF_EXPR): Moved here from cp-tree.def.
fortran/
* array.c (gfc_match_array_ref): Fix up memset arguments.
testsuite/
* gcc.dg/torture/Wsizeof-pointer-memaccess1.c: New test.
From-SVN: r190467
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/invoke.texi | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index cf93dbf..ae22ca9 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -263,9 +263,9 @@ Objective-C and Objective-C++ Dialects}. -Wpointer-arith -Wno-pointer-to-int-cast @gol -Wredundant-decls @gol -Wreturn-type -Wsequence-point -Wshadow @gol --Wsign-compare -Wsign-conversion -Wstack-protector @gol --Wstack-usage=@var{len} -Wstrict-aliasing -Wstrict-aliasing=n @gol --Wstrict-overflow -Wstrict-overflow=@var{n} @gol +-Wsign-compare -Wsign-conversion -Wsizeof-pointer-memaccess @gol +-Wstack-protector -Wstack-usage=@var{len} -Wstrict-aliasing @gol +-Wstrict-aliasing=n @gol -Wstrict-overflow -Wstrict-overflow=@var{n} @gol -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{]} @gol -Wmissing-format-attribute @gol -Wswitch -Wswitch-default -Wswitch-enum -Wsync-nand @gol @@ -4327,6 +4327,16 @@ value, like assigning a signed integer expression to an unsigned integer variable. An explicit cast silences the warning. In C, this option is enabled also by @option{-Wconversion}. +@item -Wsizeof-pointer-memaccess +@opindex Wsizeof-pointer-memaccess +@opindex Wno-sizeof-pointer-memaccess +Warn for suspicious length parameters to certain string and memory built-in +functions if the argument uses @code{sizeof}. This warning warns e.g.@: +about @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not an array, +but a pointer, and suggests a possible fix, or about +@code{memcpy (&foo, ptr, sizeof (&foo));}. This warning is enabled by +@option{-Wall}. + @item -Waddress @opindex Waddress @opindex Wno-address |