aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorSilvius Rus <rus@google.com>2007-05-11 16:20:08 +0000
committerSilvius Rus <rus@google.com>2007-05-11 16:20:08 +0000
commitde95713adb9bff72493c79c9f2d74000572e4b32 (patch)
treef0873ca8d26c98fe6770ac353fa336c975e5e22a /gcc/doc
parentc318f02020ae93847f4e64061a6ce50ae2caea6e (diff)
gcc/
* Makefile.in (OBJS-common): Add tree-ssa-alias-warnings.o. * c-common.c (strict_aliasing_warning): Modify -Wstrict-aliasing logic. * c-common.h (strict_aliasing_warning): Change return type. * c-opts.c (c_common_handle_option): Add call to set_Wstrict_aliasing. * c-typeck.c (build_indirect_ref): Add call to strict_aliasing_warning. (build_c_cast): Condition call to strict_aliasing_warning. * doc/invoke.texi: Update description of -Wstrict-aliasing[=n]. * flags.h (set_Wstrict_aliasing): Declare. * opts.c (set_Wstrict_alising): Define, add call to. * tree-flow.h (strict_aliasing_warning_backend): Declare. * tree-ssa-alias-warnings.c: New file. * tree-ssa-alias.c (compute_may_aliases): Add call to strict_aliasing_warning_backend. gcc/cp * cp/typeck.c (build_indirect_ref): Add call to strict_aliasing_warning. (build_reinterpret_cast_1): Condition call to strict_aliasing_warning. gcc/testsuite * gcc.dg/Wstrict-aliasing-bogus-const-ptr-nonconst-ptr.c: New test. * gcc.dg/Wstrict-aliasing-bogus-never-dereferenced.c: New test. * gcc.dg/Wstrict-aliasing-bogus-struct-included.c: New test. * gcc.dg/Wstrict-aliasing-converted-assigned.c: New test. * gcc.dg/Wstrict-aliasing-float-ptr-int-obj.c: New test. * gcc.dg/alias-1.c: Update option: -Wstrict-aliasing=2. * gcc.dg/alias-9.c: Update option: -Wstrict-aliasing=2. * g++.dg/warn/Wstrict-aliasing-7.C: Update option: -Wstrict-aliasing=2. * g++.dg/warn/Wstrict-aliasing-bogus-base-derived.C: New test. * g++.dg/warn/Wstrict-aliasing-bogus-char-1.C: New test. * g++.dg/warn/Wstrict-aliasing-bogus-const.C: New test. * g++.dg/warn/Wstrict-aliasing-bogus-nested-arrays.C: New test. * g++.dg/warn/Wstrict-aliasing-bogus-signed-unsigned.C: New test. * g++.dg/warn/Wstrict-aliasing-bogus-struct-included.C: New test. * g++.dg/warn/Wstrict-aliasing-bogus-union.C: New test. * g++.dg/warn/Wstrict-aliasing-float-ref-int-obj.C: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@124622 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/invoke.texi38
1 files changed, 32 insertions, 6 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 9e76394146c..9b0d65ac709 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -248,7 +248,7 @@ Objective-C and Objective-C++ Dialects}.
-Wredundant-decls @gol
-Wreturn-type -Wsequence-point -Wshadow @gol
-Wsign-compare -Wstack-protector @gol
--Wstrict-aliasing -Wstrict-aliasing=2 @gol
+-Wstrict-aliasing -Wstrict-aliasing=n @gol
-Wstrict-overflow -Wstrict-overflow=@var{n} @gol
-Wswitch -Wswitch-default -Wswitch-enum @gol
-Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol
@@ -3008,14 +3008,40 @@ It warns about code which might break the strict aliasing rules that the
compiler is using for optimization. The warning does not catch all
cases, but does attempt to catch the more common pitfalls. It is
included in @option{-Wall}.
+It is equivalent to -Wstrict-aliasing=3
-@item -Wstrict-aliasing=2
-@opindex Wstrict-aliasing=2
+@item -Wstrict-aliasing=n
+@opindex Wstrict-aliasing=n
This option is only active when @option{-fstrict-aliasing} is active.
It warns about code which might break the strict aliasing rules that the
-compiler is using for optimization. This warning catches more cases than
-@option{-Wstrict-aliasing}, but it will also give a warning for some ambiguous
-cases that are safe.
+compiler is using for optimization.
+Higher levels correspond to higher accuracy (fewer false positives).
+Higher levels also correspond to more effort, similar to the way -O works.
+@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=n},
+with n=3.
+
+Level 1: Most aggressive, quick, least accurate.
+Possibly useful when higher levels
+do not warn but -fstrict-aliasing still breaks the code, as it has very few
+false negatives. However, it has many false positives.
+Warns for all pointer conversions between possibly incompatible types,
+even if never dereferenced. Runs in the frontend only.
+
+Level 2: Aggressive, quick, not too precise.
+May still have many false positives (not as many as level 1 though),
+and few false negatives (but possibly more than level 1).
+Unlike level 1, it only warns when an address is taken. Warns about
+incomplete types. Runs in the frontend only.
+
+Level 3 (default for @option{-Wstrict-aliasing}):
+Should have very few false positives and few false
+negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
+Takes care of the common punn+dereference pattern in the frontend:
+@code{*(int*)&some_float}.
+If optimization is enabled, it also runs in the backend, where it deals
+with multiple statement cases using flow-sensitive points-to information.
+Only warns when the converted pointer is dereferenced.
+Does not warn about incomplete types.
@item -Wstrict-overflow
@item -Wstrict-overflow=@var{n}