diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/pr16302.c | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr16302.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/pr16302.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr16302.c b/gcc/testsuite/gcc.dg/pr16302.c new file mode 100644 index 000000000..0daa513ff --- /dev/null +++ b/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; +} + |