summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wparentheses-2.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-17 09:20:51 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-17 09:20:51 +0000
commit655109c8a29eb7ea5c4254f01a6367dc07d921b0 (patch)
treee4dd6ebe816e96ed4438c19008d235f68f8c19fc /gcc/testsuite/gcc.dg/Wparentheses-2.c
parent6a4e0750ccf988d9a9684da0bf9a858f358e706c (diff)
downloadgcc-655109c8a29eb7ea5c4254f01a6367dc07d921b0.tar.gz
* c-typeck.c (parser_build_binary_op): Condition warnings for
X<=Y<=Z on -Wparentheses instead of -Wextra. * doc/invoke.texi: Update. Document that most of -Wparentheses is supported for C only. testsuite: * gcc.dg/Wparentheses-2.c, gcc.dg/Wparentheses-3.c, gcc.dg/Wparentheses-4.c, Wparentheses-5.c, Wparentheses-6.c, Wparentheses-7.c, Wparentheses-8.c, Wparentheses-9.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84860 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wparentheses-2.c')
-rw-r--r--gcc/testsuite/gcc.dg/Wparentheses-2.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/Wparentheses-2.c b/gcc/testsuite/gcc.dg/Wparentheses-2.c
new file mode 100644
index 00000000000..e4110a8ceed
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wparentheses-2.c
@@ -0,0 +1,67 @@
+/* Test operation of -Wparentheses. Warnings for X<=Y<=Z should be
+ there rather than hidden in -Wextra. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+
+/* { dg-do compile } */
+/* { dg-options "-Wparentheses" } */
+
+int foo (int);
+
+int
+bar (int a, int b, int c)
+{
+ foo (a <= b <= c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((a <= b) <= c);
+ foo (a <= (b <= c));
+ foo (1 <= 2 <= c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 <= 2) <= c);
+ foo (1 <= (2 <= c));
+ foo (1 <= 2 <= 3); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 <= 2) <= 3);
+ foo (1 <= (2 <= 3));
+ foo (a > b > c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((a > b) > c);
+ foo (a > (b > c));
+ foo (1 > 2 > c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 > 2) > c);
+ foo (1 > (2 > c));
+ foo (1 > 2 > 3); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 > 2) > 3);
+ foo (1 > (2 > 3));
+ foo (a < b <= c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((a < b) <= c);
+ foo (a < (b <= c));
+ foo (1 < 2 <= c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 < 2) <= c);
+ foo (1 < (2 <= c));
+ foo (1 < 2 <= 3); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 < 2) <= 3);
+ foo (1 < (2 <= 3));
+ foo (a <= b > c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((a <= b) > c);
+ foo (a <= (b > c));
+ foo (1 <= 2 > c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 <= 2) > c);
+ foo (1 <= (2 > c));
+ foo (1 <= 2 > 3); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 <= 2) > 3);
+ foo (1 <= (2 > 3));
+ foo (a <= b == c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((a <= b) == c);
+ foo (a <= (b == c));
+ foo (1 <= 2 == c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 <= 2) == c);
+ foo (1 <= (2 == c));
+ foo (1 <= 2 == 3); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 <= 2) == 3);
+ foo (1 <= (2 == 3));
+ foo (a != b != c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((a != b) != c);
+ foo (a != (b != c));
+ foo (1 != 2 != c); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 != 2) != c);
+ foo (1 != (2 != c));
+ foo (1 != 2 != 3); /* { dg-warning "comparison" "correct warning" } */
+ foo ((1 != 2) != 3);
+ foo (1 != (2 != 3));
+}