Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.benjamin/bool02.C

raw
1 // { dg-do run }
2 //980324 bkoz
3 //test for bool and bitwise ands
4
5 #include <assert.h>
6
7
8 void bar ( bool x ) {}
9 void bars ( short x ) {}
10
11 #if 0
12 int andb(){
13 bool y;
14 bar ( y );
15 int blob = ( 27 & int (y) );
16 return blob; //expect 1 or 0
17 }
18 #endif
19
20 int andbtrue(){
21 bool y = true;
22 bar ( y );
23 int blob = ( 27 & int (y) );
24 return blob; //expect 1
25 }
26
27 int andbfalse(){
28 bool y = false;
29 bar ( y );
30 int blob = ( 27 & int (y) );
31 return blob; //expect 0
32 }
33
34 int andbfalse2(){
35 bool y = 0;
36 bar ( y );
37 int blob = ( 27 & int (y) );
38 return blob; //expect 0
39 }
40
41 int ands(){
42 short y = 1;
43 bars ( y );
44 int blob = ( 27 & int (y) );
45 return blob; //expect 1
46 }
47
48
49 int main() {
50 int tmp;
51 #if 0
52 tmp = andb();
53 assert (tmp == 1 || tmp == 0);
54 #endif
55 tmp = andbtrue();
56 assert (tmp == 1);
57 tmp = andbfalse();
58 assert (tmp == 0);
59 tmp = andbfalse2();
60 assert (tmp == 0);
61 tmp = ands();
62 assert (tmp == 1);
63 return 0;
64 }