This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch proposes a new option -Waddress to warn about suspicious uses of memory addresses. A follow-up patch will add again -Walways-true but this time actually warning for what its description says it should warn.
This new option replaces 3 warnings: -Walways-true, -Wstring-literal-comparison and an unconditional warning for a bare reference to a function used in void context.
Replacing -Walways-true will prevent future confusion between the original intent of -Walways-true and its name and description. This has been explained in detail elsewhere [1]. The current mismatch is leading to a situation similar to Wconversion, where the original intent of the option is conflicting with the perceived meaning, but worse in this case, since the perceived meaning is sanctioned by the manual page but not by the implementation.
Even GCC developers are being confused by the current situation [2]. I think we should fix this before a version of GCC with the current -Walways-true is publicly released.
Also, there are other warnings that would be more suitable for -Walways-true but they won't be for -Waddress [3]. This patch 'frees' -Walways-true so it can be used for those warnings. Once this patch is approved I will submit a follow-up for the new -Walways-true.
As for replacing -Wstrong-literal-comparison, its purpose matches -Waddress and since it is a stated goal to avoid multiplication of options as much as possible, I think it makes sense to integrate it (and the name is shorter and nicer). But this is a secondary goal, fixing -Walways-true is more important.
Lastly, the unconditional warning matched the original intent of -Walways-true, however it didn't match its description. It matches -Waddress, though.
[1] http://gcc.gnu.org/ml/gcc/2007-01/msg00480.html [2] http://sourceware.org/ml/gdb-patches/2006-12/msg00351.html [3] http://gcc.gnu.org/ml/gcc-patches/2007-01/msg01933.html
* c.opt (Waddress): New. * common.opt (Walways-true): Delete. (Wstring-literal-comparison): Delete. * doc/invoke.texi (Warning Options): Delete -Walways-true and -Wstring-literal-comparison. Add -Waddress. (Waddress): New. (Walways-true): Delete. (Wstring-literal-comparison): Delete. * doc/extend.texi (#pragma GCC diagnostic): Use -Wformat consistently instead of -Walways-true in example. * c-opts.c (c_common_handle_option): -Waddress is enabled by -Wall. * c-typeck.c (parser_build_binary_op): Replace -Wstring-literal-comparison and -Walways-true with -Waddress. * c-common.c (c_common_truthvalue_conversion): Replace -Walways-true with -Waddress.
cp/ * typeck.c (build_binary_op): Replace -Wstring-literal-comparison and -Walways-true with -Waddress. * cvt.c (convert_to_void): Replace unconditional warning with -Waddress.
testsuite/ * gcc.dg/20031012-1.c: Replace -Walways-true with -Waddress. * gcc.dg/Walways-true-1.c: Likewise. * gcc.dg/weak/weak-3.c: Likewise. * gcc.dg/Werror-1.c: Likewise. * gcc.dg/Werror-3.c: Likewise. * gcc.dg/Werror-4.c: Likewise. * gcc.dg/Werror-5.c: Likewise. * gcc.dg/Werror-6.c: Likewise. * gcc.dg/Werror-7.c: Likewise. * gcc.dg/Werror-8.c: Likewise. * gcc.dg/Werror-10.c: Likewise. * gcc.dg/Werror-11.c: Likewise. * gcc.dg/Werror-12.c: Likewise. * g++.old-deja/g++.mike/warn8.C: Likewise. * g++.dg/warn/Walways-true-1.C: Likewise. * g++.dg/warn/Walways-true-2.C: Likewise. * g++.dg/warn/noeffect8.C: Warn only with -Waddress. * g++.dg/warn/Wstring-literal-comparison-1.C: Replace -Wstring-literal-comparison with -Waddress. * gcc.dg/Wstring-literal-comparison-4.c: Replace -Wno-string-literal-comparison with -Wno-address.
Attachment:
waddress.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |