1 // { dg-do run } 2 //980324 bkoz 3 //test for bool and bitwise ands 4 5 #include <assert.h> 6 7 bar(bool x)8void bar ( bool x ) {} bars(short x)9void 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 andbtrue()20int andbtrue(){ 21 bool y = true; 22 bar ( y ); 23 int blob = ( 27 & int (y) ); 24 return blob; //expect 1 25 } 26 andbfalse()27int andbfalse(){ 28 bool y = false; 29 bar ( y ); 30 int blob = ( 27 & int (y) ); 31 return blob; //expect 0 32 } 33 andbfalse2()34int andbfalse2(){ 35 bool y = 0; 36 bar ( y ); 37 int blob = ( 27 & int (y) ); 38 return blob; //expect 0 39 } 40 ands()41int ands(){ 42 short y = 1; 43 bars ( y ); 44 int blob = ( 27 & int (y) ); 45 return blob; //expect 1 46 } 47 48 main()49int 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 } 65