diff options
author | Marek Polacek <polacek@redhat.com> | 2016-08-29 18:13:13 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2016-08-29 18:13:13 +0000 |
commit | 3d06b6f2fd3258e2d9ab18e034f0bacb06a9d062 (patch) | |
tree | e0cc10a7ba309ea1849abdf54d42b9c1a5e726b7 /gcc/c-family/c-common.c | |
parent | 6ac852d15367db402f94828810c9483f76492ac5 (diff) | |
download | gcc-3d06b6f2fd3258e2d9ab18e034f0bacb06a9d062.zip gcc-3d06b6f2fd3258e2d9ab18e034f0bacb06a9d062.tar.gz gcc-3d06b6f2fd3258e2d9ab18e034f0bacb06a9d062.tar.bz2 |
re PR c/77292 (Spurious warning: logical not is only applied to the left hand side of comparison)
PR c/77292
* c-common.c (warn_logical_not_parentheses): Don't warn for
a comparison or a logical operator.
* c-c++-common/Wlogical-not-parentheses-1.c: New test.
From-SVN: r239833
Diffstat (limited to 'gcc/c-family/c-common.c')
-rw-r--r-- | gcc/c-family/c-common.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 00f19ff..b29334a 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1481,7 +1481,8 @@ warn_tautological_cmp (location_t loc, enum tree_code code, tree lhs, tree rhs) /* Warn about logical not used on the left hand side operand of a comparison. This function assumes that the LHS is inside of TRUTH_NOT_EXPR. - Do not warn if RHS is of a boolean type. */ + Do not warn if RHS is of a boolean type, a logical operator, or + a comparison. */ void warn_logical_not_parentheses (location_t location, enum tree_code code, @@ -1489,7 +1490,8 @@ warn_logical_not_parentheses (location_t location, enum tree_code code, { if (TREE_CODE_CLASS (code) != tcc_comparison || TREE_TYPE (rhs) == NULL_TREE - || TREE_CODE (TREE_TYPE (rhs)) == BOOLEAN_TYPE) + || TREE_CODE (TREE_TYPE (rhs)) == BOOLEAN_TYPE + || truth_value_p (TREE_CODE (rhs))) return; /* Don't warn for !x == 0 or !y != 0, those are equivalent to |