blob: a6f1a457407d7b80376db269fb97201dd8e18265 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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;
}
|