Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.2:Update
libgcj41
parentheses-mathematical-5.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File parentheses-mathematical-5.diff of Package libgcj41
--- gcc/c-typeck.c +++ gcc/c-typeck.c @@ -2553,13 +2553,23 @@ warning (OPT_Wparentheses, "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 (code1) == tcc_comparison - || TREE_CODE_CLASS (code2) == 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 (code1) == tcc_comparison + || TREE_CODE_CLASS (code2) == 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 (code1) == tcc_comparison + && code1 != NE_EXPR && code1 != EQ_EXPR) + || (TREE_CODE_CLASS (code2) == tcc_comparison + && code2 != NE_EXPR && code2 != EQ_EXPR)) + warning (OPT_Wparentheses, "comparisons like X<=Y<=Z do not " + "have their mathematical meaning"); + } } unsigned_conversion_warning (result.value, arg1.value); --- gcc/testsuite/gcc.dg/Wparentheses-2.c +++ gcc/testsuite/gcc.dg/Wparentheses-2.c @@ -10,58 +10,112 @@ int bar (int a, int b, int c) { - foo (a <= b <= c); /* { dg-warning "comparison" "correct warning" } */ + foo (a <= b <= c); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((a <= b) <= c); foo (a <= (b <= c)); - foo (1 <= 2 <= c); /* { dg-warning "comparison" "correct warning" } */ + foo (1 <= 2 <= c); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((1 <= 2) <= c); foo (1 <= (2 <= c)); - foo (1 <= 2 <= 3); /* { dg-warning "comparison" "correct warning" } */ + foo (1 <= 2 <= 3); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((1 <= 2) <= 3); foo (1 <= (2 <= 3)); - foo (a > b > c); /* { dg-warning "comparison" "correct warning" } */ + foo (a > b > c); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((a > b) > c); foo (a > (b > c)); - foo (1 > 2 > c); /* { dg-warning "comparison" "correct warning" } */ + foo (1 > 2 > c); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((1 > 2) > c); foo (1 > (2 > c)); - foo (1 > 2 > 3); /* { dg-warning "comparison" "correct warning" } */ + foo (1 > 2 > 3); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((1 > 2) > 3); foo (1 > (2 > 3)); - foo (a < b <= c); /* { dg-warning "comparison" "correct warning" } */ + foo (a < b <= c); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((a < b) <= c); foo (a < (b <= c)); - foo (1 < 2 <= c); /* { dg-warning "comparison" "correct warning" } */ + foo (1 < 2 <= c); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((1 < 2) <= c); foo (1 < (2 <= c)); - foo (1 < 2 <= 3); /* { dg-warning "comparison" "correct warning" } */ + foo (1 < 2 <= 3); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((1 < 2) <= 3); foo (1 < (2 <= 3)); - foo (a <= b > c); /* { dg-warning "comparison" "correct warning" } */ + foo (a <= b > c); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((a <= b) > c); foo (a <= (b > c)); - foo (1 <= 2 > c); /* { dg-warning "comparison" "correct warning" } */ + foo (1 <= 2 > c); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((1 <= 2) > c); foo (1 <= (2 > c)); - foo (1 <= 2 > 3); /* { dg-warning "comparison" "correct warning" } */ + foo (1 <= 2 > 3); /* { dg-warning "mathematical meaning" "correct warning" } */ foo ((1 <= 2) > 3); foo (1 <= (2 > 3)); - foo (a <= b == c); /* { dg-warning "comparison" "correct warning" } */ + foo (a <= b == c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ foo ((a <= b) == c); foo (a <= (b == c)); - foo (1 <= 2 == c); /* { dg-warning "comparison" "correct warning" } */ + foo (1 <= 2 == c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ foo ((1 <= 2) == c); foo (1 <= (2 == c)); - foo (1 <= 2 == 3); /* { dg-warning "comparison" "correct warning" } */ + foo (1 <= 2 == 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ foo ((1 <= 2) == 3); foo (1 <= (2 == 3)); - foo (a != b != c); /* { dg-warning "comparison" "correct warning" } */ + foo (a != b != c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ foo ((a != b) != c); foo (a != (b != c)); - foo (1 != 2 != c); /* { dg-warning "comparison" "correct warning" } */ + foo (1 != 2 != c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ foo ((1 != 2) != c); foo (1 != (2 != c)); - foo (1 != 2 != 3); /* { dg-warning "comparison" "correct warning" } */ + foo (1 != 2 != 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ foo ((1 != 2) != 3); foo (1 != (2 != 3)); + foo (a < b == c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a < b) == c); + foo (a < (b == c)); + foo (a > b == c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a > b) == c); + foo (a > (b == c)); + foo (a == b < c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a == b) < c); + foo (a == (b < c)); + foo (a == b > c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a == b) > c); + foo (a == (b > c)); + foo (a == b == c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a == b) == c); + foo (a == (b == c)); + foo (1 == 2 == 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 == 2) == 3); + foo (1 == (2 == 3)); + foo (1 < 2 == 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 < 2) == 3); + foo (1 < (2 == 3)); + foo (1 > 2 == 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 > 2) == 3); + foo (1 > (2 == 3)); + foo (1 == 2 < 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 == 2) < 3); + foo (1 == (2 < 3)); + foo (1 == 2 > 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 == 2) > 3); + foo (1 == (2 > 3)); + foo (a < b != c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a < b) != c); + foo (a < (b != c)); + foo (a > b != c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a > b) != c); + foo (a > (b != c)); + foo (a != b < c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a != b) < c); + foo (a != (b < c)); + foo (a != b > c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a != b) > c); + foo (a != (b > c)); + foo (1 < 2 != 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 < 2) != 3); + foo (1 < (2 != 3)); + foo (1 > 2 != 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 > 2) != 3); + foo (1 > (2 != 3)); + foo (1 != 2 < 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 != 2) < 3); + foo (1 != (2 < 3)); + foo (1 != 2 > 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 != 2) > 3); + foo (1 != (2 > 3)); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor