1// { dg-do run } 2//980323 bkoz 3//test for bools with inclusive ors 4 5#include <assert.h> 6#include <limits.h> 7 8void bar ( bool x ) {} 9void bars ( short x ) {} 10 11/* 980326 bkoz this is not initialized and so can have indeterminate value. */ 12#if 0 13int orb(){ 14 bool y; 15 bar ( y ); 16 int blob = ( 27 | int (y) ); 17 return blob; //expect 27 or 0 18} 19#endif 20 21int orbtrue(){ 22 bool y = true; 23 bar ( y ); 24 int blob = ( 27 | int (y) ); 25 return blob; //expect 27 26} 27 28int orbfalse(){ 29 bool y = false; 30 bar ( y ); 31 int blob = ( 27 | int (y) ); 32 return blob; //expect 27 33} 34 35int orbfalse2(){ 36 bool y = 0; 37 bar ( y ); 38 int blob = ( 27 | int (y) ); 39 return blob; //expect 27 40} 41 42int ors(){ 43 short y = 1; 44 bars ( y ); 45 int blob = ( 27 | int (y) ); 46 return blob; //expect 27 47} 48 49 50#if INT_MAX > 32767 51int orus(){ 52 unsigned short y = 1; 53 bars ( y ); 54 int blob = ( 65539 | int (y) ); 55 return blob; //expect 65539, will be 3 if done in us type 56} 57#endif 58 59int main() { 60 int tmp; 61#if 0 62 tmp = orb(); 63 assert (tmp == 27 || tmp == 0); 64#endif 65 tmp = orbtrue(); 66 assert (tmp ==27); 67 tmp = orbfalse(); 68 assert (tmp ==27); 69 tmp = orbfalse2(); 70 assert (tmp ==27); 71 tmp = ors(); 72 assert (tmp ==27); 73#if INT_MAX > 32767 74 tmp = orus(); 75 assert (tmp == 65539); 76#endif 77 78 return 0; 79} 80 81