summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wlogical-op-1.c
blob: 462b90beaf3588a2c75649be6235aa180670ee6a (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
77
/*
   { dg-do compile }
   { dg-options "-Wlogical-op" }
*/

enum { a, ba, b };

enum testenum { t1, t2};

extern int c;
extern char bool_a, bool_b;

extern int testa();

void foo()
{
    if ( testa() && b )     /* { dg-warning "logical" } */
         (void)testa();

    if ( c && b )           /* { dg-warning "logical" } */
	(void)testa();

    if ( c && 0x42 )        /* { dg-warning "logical" } */
	(void)testa();

    if ( c && 0x80 >>6)     /* { dg-warning "logical" } */
	(void)testa();


    if ( b && c == a )      /* { dg-bogus "logical" } */
          (void)testa();

    if ( 1 && c )           /* { dg-bogus "logical" } */
         (void)testa();

    if ( t2 && b )          /* { dg-bogus "logical" } */
          (void)testa();

    if ( 0 && c == a )      /* { dg-bogus "logical" } */
          (void)testa();

    if ( b && 1 )           /* { dg-bogus "logical" } */
          (void)testa();
}


void bar()
{
    if ( testa() || b )     /* { dg-warning "logical" } */
         (void)testa();

    if ( c || b )           /* { dg-warning "logical" } */
	(void)testa();

    if ( c || 0x42 )        /* { dg-warning "logical" } */
	(void) testa();

    if ( c || 0x80 >>6)     /* { dg-warning "logical" } */
	(void)testa();


    if ( b || c == a )      /* { dg-bogus "logical" } */
          (void)testa();

    if ( 1 || c )           /* { dg-bogus "logical" } */
         (void)testa();

    if ( t2 || b )          /* { dg-bogus "logical" } */
          (void)testa();

    if ( 0 || c == a )      /* { dg-bogus "logical" } */
          (void)testa();

    if ( b || 1 )           /* { dg-bogus "logical" } */
          (void)testa();
}