| Summary: | [6 Regression] -Wnonnull diagnoses parameter comparisons with NULL even when those could have changed | ||
|---|---|---|---|
| Product: | gcc | Reporter: | Jakub Jelinek <jakub> |
| Component: | c | Assignee: | Jakub Jelinek <jakub> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | mark |
| Priority: | P3 | ||
| Version: | 6.0 | ||
| Target Milestone: | 6.0 | ||
| Host: | Target: | ||
| Build: | Known to work: | ||
| Known to fail: | Last reconfirmed: | 2016-02-16 00:00:00 | |
| Attachments: | gcc6-pr69835.patch | ||
Created attachment 37703 [details] gcc6-pr69835.patch Untested fix, which moves the warning from the FE to early uninit pass (i.e. shortly after going into SSA). Author: jakub Date: Tue Feb 16 20:46:17 2016 New Revision: 233472 URL: https://gcc.gnu.org/viewcvs?rev=233472&root=gcc&view=rev Log: PR c/69835 * common.opt (Wnonnull-compare): New warning. * doc/invoke.texi (-Wnonnull): Remove text about comparison of arguments against NULL. (-Wnonnull-compare): Document. * Makefile.in (OBJS): Add gimple-ssa-nonnull-compare.o. * tree-pass.h (make_pass_warn_nonnull_compare): Declare. * passes.def (pass_warn_nonnull_compare): Add. * gimple-ssa-nonnull-compare.c: New file. c-family/ * c.opt (Wnonnull-compare): Enable for -Wall. c/ * c-typeck.c (build_binary_op): Revert 2015-09-09 change. cp/ * typeck.c (cp_build_binary_op): Revert 2015-09-09 change. testsuite/ * c-c++-common/nonnull-1.c: Use -Wnonnull-compare instead of -Wnonnull in dg-options. * c-c++-common/nonnull-2.c: New test. Added: trunk/gcc/gimple-ssa-nonnull-compare.c trunk/gcc/testsuite/c-c++-common/nonnull-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/Makefile.in trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c.opt trunk/gcc/c/ChangeLog trunk/gcc/c/c-typeck.c trunk/gcc/common.opt trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck.c trunk/gcc/doc/invoke.texi trunk/gcc/passes.def trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/c-c++-common/nonnull-1.c trunk/gcc/tree-pass.h Fixed. |
-Wnonnull warns even about: static void f(const char *s) { do { printf("%s\n",s); s = NULL; } while (s != NULL); } which is wrong, after the parameter has been changed or could have been changed, it is completely valid to compare it against NULL.