annotate gcc/testsuite/g++.dg/warn/pr16302.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // PR 16302
kono
parents:
diff changeset
2 /* { dg-do compile } */
kono
parents:
diff changeset
3 /* { dg-options "-Wlogical-op" } */
kono
parents:
diff changeset
4 void bar (int);
kono
parents:
diff changeset
5 int
kono
parents:
diff changeset
6 foo (int argc, char *argv[])
kono
parents:
diff changeset
7 {
kono
parents:
diff changeset
8 if (argc != 1 || argc != 2) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
9 if (argc < 0 && argc > 10) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
10 if (argc || !argc) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
11 if (argc && !argc) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
12 bar (argc != 1 || argc != 2); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
13 bar (argc < 0 && argc > 10); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
14 bar (argc || !argc); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
15 bar (argc && !argc); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
16 return (argc != 1 || argc != 2) ? 1 : 0 ; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
17 return (argc < 0 && argc > 10) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
18 return (argc || !argc) ? 1 : 0; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
19 return (argc && !argc) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 if (argc == 2 && argc == 1) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
22 if (argc < 0 && argc > 10) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
23 if (argc || !argc) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
24 if (argc && !argc) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
25 bar (argc == 2 && argc == 1); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
26 bar (argc < 0 && argc > 10); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
27 bar (argc || !argc); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
28 bar (argc && !argc); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
29 return (argc == 2 && argc == 1) ? 1 : 0 ; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
30 return (argc < 0 && argc > 10) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
31 return (argc || !argc) ? 1 : 0; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
32 return (argc && !argc) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 if (argc == 2 && argc == 1) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
35 if (argc < 0 && argc > 10) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
36 if (!argc || argc) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
37 if (!argc && argc) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
38 bar (argc == 2 && argc == 1); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
39 bar (argc < 0 && argc > 10); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
40 bar (!argc || argc); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
41 bar (!argc && argc); /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
42 return (argc == 2 && argc == 1) ? 1 : 0 ; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
43 return (argc < 0 && argc > 10) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
44 return (!argc || argc) ? 1 : 0; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */
kono
parents:
diff changeset
45 return (!argc && argc) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 return 0;
kono
parents:
diff changeset
48 }
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 int
kono
parents:
diff changeset
51 foo2 (int argc)
kono
parents:
diff changeset
52 {
kono
parents:
diff changeset
53 if (5 != 1 || 5 != 2) return 1;
kono
parents:
diff changeset
54 if (5 < 0 && 5 > 10) return 1;
kono
parents:
diff changeset
55 if (1 || 0) return 1;
kono
parents:
diff changeset
56 if (0 && 1) return 1;
kono
parents:
diff changeset
57 if (2 || !2) return 1;
kono
parents:
diff changeset
58 if (2 && !2) return 1;
kono
parents:
diff changeset
59 if (!(!2) || !(2)) return 1;
kono
parents:
diff changeset
60 if (!(!2) && !(2)) return 1;
kono
parents:
diff changeset
61 bar (5 != 1 || 5 != 2);
kono
parents:
diff changeset
62 bar (5 < 0 && 5 > 10);
kono
parents:
diff changeset
63 bar (1 || 0);
kono
parents:
diff changeset
64 bar (0 && 1);
kono
parents:
diff changeset
65 bar (2 || !2);
kono
parents:
diff changeset
66 bar (2 && !2);
kono
parents:
diff changeset
67 return (5 != 1 || 5 != 2) ? 1 : 0 ;
kono
parents:
diff changeset
68 return (5 < 0 && 5 > 10) ? 1 : 0;
kono
parents:
diff changeset
69 return (1 || 0) ? 1 : 0 ;
kono
parents:
diff changeset
70 return (0 && 1) ? 1 : 0;
kono
parents:
diff changeset
71 return (2 || !2) ? 1 : 0;
kono
parents:
diff changeset
72 return (2 && !2) ? 1 : 0;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 return 0;
kono
parents:
diff changeset
75 }
kono
parents:
diff changeset
76