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