aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/gcc/testsuite/gcc.dg/pr16302.c
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2013-03-28 11:14:20 -0700
committerBen Cheng <bccheng@google.com>2013-03-28 12:40:33 -0700
commitaf0c51ac87ab2a87caa03fa108f0d164987a2764 (patch)
tree4b8b470f7c5b69642fdab8d0aa1fbc148d02196b /gcc-4.8/gcc/testsuite/gcc.dg/pr16302.c
parentd87cae247d39ebf4f5a6bf25c932a14d2fdb9384 (diff)
downloadtoolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.tar.gz
toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.tar.bz2
toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.zip
[GCC 4.8] Initial check-in of GCC 4.8.0
Change-Id: I0719d8a6d0f69b367a6ab6f10eb75622dbf12771
Diffstat (limited to 'gcc-4.8/gcc/testsuite/gcc.dg/pr16302.c')
-rw-r--r--gcc-4.8/gcc/testsuite/gcc.dg/pr16302.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/pr16302.c b/gcc-4.8/gcc/testsuite/gcc.dg/pr16302.c
new file mode 100644
index 000000000..0daa513ff
--- /dev/null
+++ b/gcc-4.8/gcc/testsuite/gcc.dg/pr16302.c
@@ -0,0 +1,76 @@
+/* PR 16302 */
+/* { dg-do compile } */
+/* { dg-options "-Wlogical-op" } */
+void bar (int);
+int
+foo (int argc, char *argv[])
+{
+ if (argc != 1 || argc != 2) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ if (argc < 0 && argc > 10) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ if (argc || !argc) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ if (argc && !argc) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ bar (argc != 1 || argc != 2); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ bar (argc < 0 && argc > 10); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ bar (argc || !argc); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ bar (argc && !argc); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ return (argc != 1 || argc != 2) ? 1 : 0 ; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ return (argc < 0 && argc > 10) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ return (argc || !argc) ? 1 : 0; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ return (argc && !argc) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+
+ if (argc == 2 && argc == 1) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ if (argc < 0 && argc > 10) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ if (argc || !argc) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ if (argc && !argc) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ bar (argc == 2 && argc == 1); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ bar (argc < 0 && argc > 10); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ bar (argc || !argc); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ bar (argc && !argc); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ return (argc == 2 && argc == 1) ? 1 : 0 ; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ return (argc < 0 && argc > 10) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ return (argc || !argc) ? 1 : 0; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ return (argc && !argc) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+
+ if (argc == 2 && argc == 1) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ if (argc < 0 && argc > 10) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ if (!argc || argc) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ if (!argc && argc) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ bar (argc == 2 && argc == 1); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ bar (argc < 0 && argc > 10); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ bar (!argc || argc); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ bar (!argc && argc); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ return (argc == 2 && argc == 1) ? 1 : 0 ; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ return (argc < 0 && argc > 10) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+ return (!argc || argc) ? 1 : 0; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
+ return (!argc && argc) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
+
+ return 0;
+}
+
+int
+foo2 (int argc)
+{
+ if (5 != 1 || 5 != 2) return 1;
+ if (5 < 0 && 5 > 10) return 1;
+ if (1 || 0) return 1;
+ if (0 && 1) return 1;
+ if (2 || !2) return 1;
+ if (2 && !2) return 1;
+ if (!(!2) || !(2)) return 1;
+ if (!(!2) && !(2)) return 1;
+ bar (5 != 1 || 5 != 2);
+ bar (5 < 0 && 5 > 10);
+ bar (1 || 0);
+ bar (0 && 1);
+ bar (2 || !2);
+ bar (2 && !2);
+ return (5 != 1 || 5 != 2) ? 1 : 0 ;
+ return (5 < 0 && 5 > 10) ? 1 : 0;
+ return (1 || 0) ? 1 : 0 ;
+ return (0 && 1) ? 1 : 0;
+ return (2 || !2) ? 1 : 0;
+ return (2 && !2) ? 1 : 0;
+
+ return 0;
+}
+