diff options
author | Ben Elliston <bje@au.ibm.com> | 2005-12-13 23:33:26 +0000 |
---|---|---|
committer | Ben Elliston <bje@gcc.gnu.org> | 2005-12-14 10:33:26 +1100 |
commit | 690a704a4e5eda3745d4b0d650cba90a36702a64 (patch) | |
tree | d72ae86b6320671af20df2fd5c12deb106455c3a /gcc/c-common.c | |
parent | 383eca9ccea8275baab7d6bdf5f464e113482dec (diff) | |
download | gcc-690a704a4e5eda3745d4b0d650cba90a36702a64.zip gcc-690a704a4e5eda3745d4b0d650cba90a36702a64.tar.gz gcc-690a704a4e5eda3745d4b0d650cba90a36702a64.tar.bz2 |
c-common.c (c_common_truthvalue_conversion): Generalise warning for addresses converted to booleans; not just function addresses.
* c-common.c (c_common_truthvalue_conversion): Generalise warning
for addresses converted to booleans; not just function addresses.
* c-typeck.c (build_binary_op): Warn for address comparisons which
can never be NULL (eg. func == NULL or &var == NULL).
* common.opt (Walways-true): New option.
* c-opts.c (c_common_handle_option): Set it with -Wall.
* doc/invoke.texi: Document it.
testsuite/
* gcc.dg/warn-addr-cmp.c: New test.
From-SVN: r108489
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 557cd55..5f97a97 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2407,12 +2407,12 @@ c_common_truthvalue_conversion (tree expr) case ADDR_EXPR: { - if (TREE_CODE (TREE_OPERAND (expr, 0)) == FUNCTION_DECL + if (DECL_P (TREE_OPERAND (expr, 0)) && !DECL_WEAK (TREE_OPERAND (expr, 0))) { /* Common Ada/Pascal programmer's mistake. We always warn about this since it is so bad. */ - warning (0, "the address of %qD, will always evaluate as %<true%>", + warning (OPT_Walways_true, "the address of %qD, will always evaluate as %<true%>", TREE_OPERAND (expr, 0)); return truthvalue_true_node; } |