diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2017-06-02 04:06:59 +0000 |
---|---|---|
committer | Bernd Edlinger <edlinger@gcc.gnu.org> | 2017-06-02 04:06:59 +0000 |
commit | 40ffd95f56ad178148612c19304a4409d0a7ebac (patch) | |
tree | 29d5e4f52493dd00dab2bb7847d93038918e9f81 /gcc/doc/invoke.texi | |
parent | 616dbacbac0a0d88551a2acafd0d84cf20f91d17 (diff) | |
download | gcc-40ffd95f56ad178148612c19304a4409d0a7ebac.zip gcc-40ffd95f56ad178148612c19304a4409d0a7ebac.tar.gz gcc-40ffd95f56ad178148612c19304a4409d0a7ebac.tar.bz2 |
invoke.texi: Document the -Wsizeof-pointer-div warning.
gcc:
2017-06-02 Bernd Edlinger <bernd.edlinger@hotmail.de>
* doc/invoke.texi: Document the -Wsizeof-pointer-div warning.
gcc/c-family:
2017-06-02 Bernd Edlinger <bernd.edlinger@hotmail.de>
* c.opt (Wsizeof-pointer-div): New warning option.
gcc/c:
2017-06-02 Bernd Edlinger <bernd.edlinger@hotmail.de>
* c-parser.c (c_parser_binary_expression): Implement the
-Wsizeof_pointer_div warning.
(c_parser_postfix_expression): Allow SIZEOF_EXPR as expr.original_code
from a parenthesized expression.
(c_parser_expr_list): Use c_last_sizeof_loc.
* c-tree.h (c_last_sizeof_loc): New external.
* c-typeck.c (c_last_sizeof_loc): New variable.
(c_expr_sizeof_expr, c_expr_sizeof_type): Assign c_last_sizeof_loc.
gcc/cp:
2017-06-02 Bernd Edlinger <bernd.edlinger@hotmail.de>
* typeck.c (cp_build_binary_op): Implement the -Wsizeof_pointer_div
warning.
gcc/testsuite:
2017-06-02 Bernd Edlinger <bernd.edlinger@hotmail.de>
* c-c++-common/Wsizeof-pointer-div.c: New test.
* gcc.dg/Wsizeof-pointer-memaccess1.c: Add test cases with parens.
* gcc.dg/torture/Wsizeof-pointer-memaccess1.c: Likewise.
* gcc.target/i386/sse-init-v4hi-1.c: Fix test case.
* gcc.target/i386/sse-init-v4sf-1.c: Likewise.
* gcc.target/i386/sse-set-ps-1.c: Likewise.
* gcc.target/i386/sse2-init-v16qi-1.c: Likewise.
* gcc.target/i386/sse2-init-v2di-1.c: Likewise.
* gcc.target/i386/sse2-init-v4si-1.c: Likewise.
* gcc.target/i386/sse2-init-v8hi-1.c: Likewise.
* gcc.target/i386/sse2-set-epi32-1.c: Likewise.
* gcc.target/i386/sse2-set-epi64x-1.c: Likewise.
* gcc.target/i386/sse4_1-init-v16qi-1.c: Likewise.
* gcc.target/i386/sse4_1-init-v2di-1.c: Likewise.
* gcc.target/i386/sse4_1-init-v4sf-1.c: Likewise.
* gcc.target/i386/sse4_1-init-v4si-1.c: Likewise.
* gcc.target/i386/sse4_1-set-epi32-1.c: Likewise.
* gcc.target/i386/sse4_1-set-epi64x-1.c: Likewise.
* gcc.target/i386/sse4_1-set-ps-1.c: Likewise.
* libgomp.c/pr39591-2.c: Likewise.
* libgomp.c/pr39591-3.c: Likewise.
From-SVN: r248811
Diffstat (limited to 'gcc/doc/invoke.texi')
-rw-r--r-- | gcc/doc/invoke.texi | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 59563aa..819e800 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -306,7 +306,7 @@ Objective-C and Objective-C++ Dialects}. -Wshift-overflow -Wshift-overflow=@var{n} @gol -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value @gol -Wsign-compare -Wsign-conversion -Wfloat-conversion @gol --Wno-scalar-storage-order @gol +-Wno-scalar-storage-order -Wsizeof-pointer-div @gol -Wsizeof-pointer-memaccess -Wsizeof-array-argument @gol -Wstack-protector -Wstack-usage=@var{len} -Wstrict-aliasing @gol -Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} @gol @@ -3832,6 +3832,7 @@ Options} and @ref{Objective-C and Objective-C++ Dialect Options}. -Wreturn-type @gol -Wsequence-point @gol -Wsign-compare @r{(only in C++)} @gol +-Wsizeof-pointer-div @gol -Wsizeof-pointer-memaccess @gol -Wstrict-aliasing @gol -Wstrict-overflow=1 @gol @@ -6093,6 +6094,15 @@ void operator delete[] (void *, std::size_t) noexcept; or vice versa. Enabled by @option{-Wextra} along with @option{-fsized-deallocation}. +@item -Wsizeof-pointer-div +@opindex Wsizeof-pointer-div +@opindex Wno-sizeof-pointer-div +Warn for suspicious divisions of two sizeof expressions that divide +the pointer size by the element size, which is the usual way to compute +the array size but won't work out correctly with pointers. This warning +warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is +not an array, but a pointer. This warning is enabled by @option{-Wall}. + @item -Wsizeof-pointer-memaccess @opindex Wsizeof-pointer-memaccess @opindex Wno-sizeof-pointer-memaccess |