diff options
author | Dirk Mueller <dmueller@suse.de> | 2007-01-31 13:43:40 +0000 |
---|---|---|
committer | Dirk Mueller <mueller@gcc.gnu.org> | 2007-01-31 13:43:40 +0000 |
commit | e7917d06e81b8ec0b763bd479861cb60e029bbb9 (patch) | |
tree | 3d17c03e4ce96fde3fa173a9f6e9fbd5991de70e /gcc/c-common.c | |
parent | d9f414687eff2b7d3b4ffbd7f0ce00d892d76a90 (diff) | |
download | gcc-e7917d06e81b8ec0b763bd479861cb60e029bbb9.zip gcc-e7917d06e81b8ec0b763bd479861cb60e029bbb9.tar.gz gcc-e7917d06e81b8ec0b763bd479861cb60e029bbb9.tar.bz2 |
c-common.c (warn_about_parentheses): Separate warning about un-parenthized sequence of comparison operators from the...
2007-01-31 Dirk Mueller <dmueller@suse.de>
* c-common.c (warn_about_parentheses): Separate warning about
un-parenthized sequence of comparison operators from the one
which is supposed to warn about x <= y <= z.
* testsuite/gcc.dg/Wparentheses-2.c: Update and add new tests.
From-SVN: r121421
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 1bd59ff..cfd3829 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -6750,12 +6750,23 @@ warn_about_parentheses (enum tree_code code, enum tree_code code_left, "suggest parentheses around comparison in operand of &"); } - /* Similarly, check for cases like 1<=i<=10 that are probably errors. */ - if (TREE_CODE_CLASS (code) == tcc_comparison - && (TREE_CODE_CLASS (code_left) == tcc_comparison - || TREE_CODE_CLASS (code_right) == tcc_comparison)) - warning (OPT_Wparentheses, "comparisons like X<=Y<=Z do not " - "have their mathematical meaning"); + if (code == EQ_EXPR || code == NE_EXPR) + { + if (TREE_CODE_CLASS (code_left) == tcc_comparison + || TREE_CODE_CLASS (code_right) == tcc_comparison) + warning (OPT_Wparentheses, + "suggest parentheses around comparison in operand of %s", + code == EQ_EXPR ? "==" : "!="); + } + else if (TREE_CODE_CLASS (code) == tcc_comparison) + { + if ((TREE_CODE_CLASS (code_left) == tcc_comparison + && code_left != NE_EXPR && code_left != EQ_EXPR) + || (TREE_CODE_CLASS (code_right) == tcc_comparison + && code_right != NE_EXPR && code_right != EQ_EXPR)) + warning (OPT_Wparentheses, "comparisons like X<=Y<=Z do not " + "have their mathematical meaning"); + } } /* If LABEL (a LABEL_DECL) has not been used, issue a warning. */ |