This previously resulted in an ICE:
cc65: Check failed: (Entry->Type->C & T_MASK_SIGN) == T_SIGN_SIGNED,
file 'cc65/symtab.c', line 874
This CHECK is in the code that deals with changing `int` bitfields to
`unsigned int`.
Work around this by treating enum bit-fields as having their signedness
specified, so this type change code does not get called.
Fixes#1244.
cl65 creates intermediate files based on the source file name in the source file directory. Calling cl65 in parallel with the same source file causes those intermediate files to get overwritten.
Fixes#1080
Prior to this PR, `int`, `signed int`, and `unsigned int`
bitfields are all treated as `unsigned int`.
With this PR, `signed int` will be treated as `signed int`,
and the others remain unsigned.
Since `Type` does not distinguish between `int` and `signed int`,
add an extra `int* SignenessSpecified` param to `ParseTypeSpec`
so we can tell these apart for bit-fields and treat plain `int : N`
as `unsigned int : N` since it is more efficient to zero-extend
than sign-extend.
Fixes#1095
Previously, the following rules were used for binary operators:
* If one of the values is a long, the result is long.
* If one of the values is unsigned, the result is also unsigned.
* Otherwise the result is an int.
C89 specifies the "usual arithmetic conversions" as:
* The integral promotions are performed on both operands.
* Then the following rules are applied:
* If either operand has type unsigned long int, the other operand is
converted to unsigned long int.
* Otherwise, if one operand has type long int and the other has type
unsigned int, if a long int can represent all values of an unsigned int,
the operand of type unsigned int is converted to long int; if a long int
cannot represent all the values of an unsigned int, both operands are
converted to unsigned long int.
* Otherwise, if either operand has type long int, the other operand is
converted to long int.
* Otherwise, if either operand has type unsigned int, the other operand is
converted to unsigned int.
* Otherwise, both operands have type int.
https://port70.net/~nsz/c/c89/c89-draft.html#3.2.1.5
As one example, these rules give a different result for an operator
with one long operand and one unsigned int operand. Previously,
the result type was unsigned long. With C89 semantics, it is just long,
since long can represent all unsigned ints.
Integral promotions convert types shorter than int to int (or unsigned int).
Both char and unsigned char are promoted to int since int can represent
all unsigned chars.
https://port70.net/~nsz/c/c89/c89-draft.html#3.2.1.1
Rename promoteint to ArithmeticConvert, since this is more accurate.
Fixes#170
Previously, bit-field tests were incorrectly combined with load in
`if (x.bitfield)`. Delay the test until after the shift/mask
is done. Still combine tests with load if no shift/mask is required.
Fixes#1139
* rand() use XOR to break up unwanted pair correlation
This form of rand() cannot return the same value twice in a row.
Two additonal EOR instructions produce a more even distribution of successive pairs.
see comments on #951
* rand.s document purpose of XOR
* suggested srand() optimization: zero fill unnecessary
* test to validate implementation of rand()
* srand() improving behaviour and adding startup test
* srand() with a tail call to rand() for better initial shuffle
* srand() can fall through to rand() instead of tail call
That lets them match old-style definitions. It avoids "Type conflict" error messages. It allows shorter function calls.
Fixed the types of some variables in "test/ref/otccex.c". It avoids crashes on 64-bit Windows (32-bit Windows with 64-bit pointers).
The test program works as-is only if the timezone isn't set (to something different than UTC). However, using localtime() instead of gmtime() makes it at least consistent in that the original time (given to mktime()) is identical to the time retrieved.