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