2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.benjamin / bool01.C
blobb9890412d331c8a801a03fb74277e8a719d079ad
1 // { dg-do run  }
2 //980323 bkoz
3 //test for bools with inclusive ors
5 #include <assert.h>
6 #include <limits.h>
8 void bar ( bool  x ) {}
9 void bars ( short  x ) {}
11 /* 980326 bkoz this is not initialized and so can have indeterminate value. */
12 #if 0
13 int orb(){
14   bool y;
15   bar ( y );
16   int blob = ( 27 | int (y) );
17   return blob; //expect 27 or 0
19 #endif
21 int orbtrue(){
22   bool y = true;
23   bar ( y );
24   int blob = ( 27 | int (y) );
25   return blob; //expect 27
28 int orbfalse(){
29   bool y = false;
30   bar ( y );
31   int blob = ( 27 | int (y) );
32   return blob; //expect 27
35 int orbfalse2(){
36   bool y = 0;
37   bar ( y );
38   int blob = ( 27 | int (y) );
39   return blob;  //expect 27
42 int ors(){
43   short y = 1;
44   bars ( y );
45   int blob = ( 27 | int (y) );
46   return blob;  //expect 27
50 #if INT_MAX > 32767
51 int 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
57 #endif
59 int 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
78   return 0;