summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.benjamin/bool02.C
blob: fcdb143a116adaa293dc61c48f1107546e81d095 (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
// { dg-do run  }
//980324 bkoz
//test for bool and bitwise ands

#include <assert.h>


void bar ( bool  x ) {}
void bars ( short  x ) {}

#if 0
int andb(){
  bool y;
  bar ( y );
  int blob = ( 27 & int (y) );
  return blob; //expect 1 or 0
}
#endif

int andbtrue(){
  bool y = true;
  bar ( y );
  int blob = ( 27 & int (y) );
  return blob; //expect 1
}

int andbfalse(){
  bool y = false;
  bar ( y );
  int blob = ( 27 & int (y) );
  return blob; //expect 0
}

int andbfalse2(){
  bool y = 0;
  bar ( y );
  int blob = ( 27 & int (y) );
  return blob;  //expect 0
}

int ands(){
  short y = 1;
  bars ( y );
  int blob = ( 27 & int (y) );
  return blob;  //expect 1
}


int main() {
  int tmp;
#if 0
  tmp = andb();
  assert (tmp == 1 || tmp == 0);
#endif
  tmp = andbtrue();
  assert (tmp == 1);
  tmp = andbfalse();
  assert (tmp == 0);
  tmp = andbfalse2();
  assert (tmp == 0);
  tmp = ands();
  assert (tmp == 1);
  return 0;
}