1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
/*
!!DESCRIPTION!!
!!ORIGIN!! SDCC regression tests
!!LICENCE!! GPL, read COPYING.GPL
*/
#include <stdio.h>
#include <limits.h>
unsigned char success=0;
unsigned char failures=0;
unsigned char dummy=0;
#if SUPPORT_BIT_TYPES
bit bit0 = 0;
bit bit1 = 0;
bit bit2 = 0;
#endif
unsigned int uint0 = 0;
unsigned int uint1 = 0;
unsigned char uchar0 = 0;
unsigned char uchar1 = 0;
unsigned long ulong0 = 0;
unsigned long ulong1 = 0;
void done()
{
dummy++;
}
/* uchar0 = 0; */
void or_lit2uchar(void)
{
if(uchar0)
failures++;
uchar0 |= 1;
if(uchar0 != 1)
failures++;
uchar0 |= 2;
if(uchar0 != 3)
failures++;
uchar0 |= 0x0e;
if(uchar0 != 0x0f)
failures++;
}
void or_lit2uint(void)
{
if(uint0)
failures++;
uint0 |= 1;
if(uint0 != 1)
failures++;
uint0 |= 2;
if(uint0 != 3)
failures++;
uint0 |= 0x100;
if(uint0 != 0x103)
failures++;
uint0 |= 0x102;
if(uint0 != 0x103)
failures++;
uint0 |= 0x303;
if(uint0 != 0x303)
failures++;
}
void or_lit2ulong(void)
{
if(ulong0)
failures++;
ulong0 |= 1;
if(ulong0 != 1)
failures++;
ulong0 |= 2;
if(ulong0 != 3)
failures++;
ulong0 |= 0x100;
if(ulong0 != 0x103)
failures++;
ulong0 |= 0x102;
if(ulong0 != 0x103)
failures++;
ulong0 |= 0x303;
if(ulong0 != 0x303)
failures++;
ulong0 |= 0x80000000;
if(ulong0 != 0x80000303)
failures++;
}
/*-----------*/
void or_uchar2uchar(void)
{
uchar0 |= uchar1;
if(uchar0 != 1)
failures++;
uchar1 |= 0x0f;
uchar0 = uchar1 | 0x10;
if(uchar0 != 0x1f)
failures++;
}
void or_uint2uint(void)
{
uint0 |= uint1;
if(uint0 != 1)
failures++;
uint1 |= 0x0f;
uint0 = uint1 | 0x10;
if(uint0 != 0x1f)
failures++;
}
#if SUPPORT_BIT_TYPES
void or_bits1(void)
{
bit0 = bit0 | bit1 | bit2;
}
void or_bits2(void)
{
bit0 = bit1 | bit2;
}
#endif
int main(void)
{
or_lit2uchar();
or_lit2uint();
or_lit2ulong();
uchar0=0;
uchar1=1;
or_uchar2uchar();
uint0=0;
uint1=1;
or_uint2uint();
#if SUPPORT_BIT_TYPES
or_bits1();
if(bit0)
failures++;
or_bits2();
if(bit0)
failures++;
bit1=1;
or_bits1();
if(!bit0)
failures++;
or_bits2();
if(!bit0)
failures++;
#endif
success = failures;
done();
printf("failures: %d\n",failures);
return failures;
}
|