1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-05 21:29:03 +00:00
Commit Graph

241 Commits

Author SHA1 Message Date
Jeff Tranter
2bf8be5b3b Fix some commonly made spelling errors in comments. 2022-02-21 15:44:31 -05:00
acqn
904a77e03c Testcase for #1675. 2022-02-18 15:20:01 +08:00
acqn
6dbafda53f Testcase for #1662. 2022-02-14 22:28:22 +08:00
mrdudz
86f1965202 added test related to issue #1552 fixed in pr #1571 2021-09-28 18:55:23 +02:00
mrdudz
6ba8a385a0 add test related tu issue #1562 2021-09-28 18:11:23 +02:00
acqn
31128d4809 Added test cases for result types of certain operations. 2021-06-10 21:54:32 +02:00
acqn
d69e81cd66 Moved and improved test cases for Issue #1462.
Fixed an old test case for unsigned enum bit-fields that are supposed to be int-promoted.
2021-06-09 08:03:12 +02:00
mrdudz
022935320c test for issue #897 2021-05-24 14:30:10 +02:00
mrdudz
0db23a8951 testcase for issue #263 2021-05-23 18:55:06 +02:00
mrdudz
4a57656f69 add test for issue #1504 2021-05-17 14:40:09 +02:00
Christian Groessler
09e0e74124 (again) remove TABs 2021-05-13 18:12:12 +02:00
mrdudz
f3663b8d2e added test for issue #1461 2021-04-28 14:21:48 +02:00
acqn
5f8d163045 Moved one test case for #1209. 2021-04-06 22:20:39 +02:00
acqn
39700c77ee Added test case for Issue #1451. 2021-04-05 15:49:54 +02:00
acqn
5d05451ab2 Fixed test case for Issue #1263. 2021-04-03 17:50:46 +02:00
acqn
cb8fbf4772 Removed the non-existing-in-C "struct/union scope" for structs/unions.
Fixed handling of struct/union field declarations without identifiers, which do nothing.
2021-03-29 19:28:22 +02:00
mrdudz
bf1bb7a032 ooopsie :) 2021-03-27 15:13:32 +01:00
mrdudz
54920193e5 added test for issue #1438 2021-03-27 15:11:47 +01:00
mrdudz
d3cd668585 also test (some of) the cases with an external function 2021-03-22 23:37:33 +01:00
mrdudz
55e89416cd test related to issue #1196 and pr #1424 respectively 2021-03-22 19:12:44 +01:00
Oliver Schmidt
203c4da15b
Merge pull request #1434 from mrdudz/test1423
Test for pr #1423
2021-03-20 02:01:46 +01:00
mrdudz
82fb9aa418 testcase related to pr #1423 2021-03-20 00:55:55 +01:00
mrdudz
bbfc24770e test related to pr #1425 2021-03-20 00:23:12 +01:00
mrdudz
cc040ca04a remove, fucking git 2021-03-19 23:39:56 +01:00
mrdudz
57e69d9647 test related to pr #1425 2021-03-19 23:35:34 +01:00
mrdudz
9ec9d1e20c test for issue #1431 / pr #1424 2021-03-19 20:53:52 +01:00
acqn
6f5ad51816 Added testcase for Issue #1408. 2021-02-23 22:06:21 +01:00
acqn
f1c715c455 Fixed a bug that pointer subtraction results from two absolute addresses are calculated as unsigned long. 2021-02-22 14:14:59 -05:00
acqn
da4cc08b78 Moved and improved test case for Issue #1310. 2021-02-22 14:14:59 -05:00
acqn
24985f1b33 Added testcase for the "deferred ops in unevaluated context" bug. 2021-02-22 11:02:47 +01:00
acqn
131f96eb1e Moved testcase for issue #1397. 2021-02-17 07:03:11 -05:00
acqn
a040c28cc4 Moved test for #1374. 2021-01-19 14:33:27 +01:00
Christian Groessler
ef258bdc19 remove TABs which again slipped in.... 2020-12-25 07:16:26 +01:00
Greg King
b2c1a77bb3 Fixed the cc65 code that optimizes 16-bit compares when the high bytes are known to be equal.
Only the low bytes are compared.  Originally, signed 16-bit compares were optimized into signed 8-bit compares.  But, the sign bits are in the high bytes; and, they're equal.  Therefore, the low bytes always must be compared as unsigned numbers.
Fixes #1348.
2020-12-24 12:27:09 -05:00
Greg King
8b42f570e9 Fixed code that caused a seg-fault after parsing a (deferred) post-count argument followed by a (nested) function-call argument.
The old broken code defers the count until the end of the (parent function's) argument list.  But, a nested function call clears the pointer to the deferred type.  That leads to an access violation.
The new code defers only until the end of each argument.  Fixes #1320.
2020-11-20 17:45:14 -05:00
Jesse Rosenstock
c2c73e7d06 Move #1332 test from todo/ to val/
This bug was fixed by 2915464.
2020-11-16 03:23:52 -05:00
Jesse Rosenstock
93145246fd Add tests for u8 op s16_const
Test expressions like `unsigned char x = ...; ... = x / 2;`
These use `int` constants with values representable by
`unsigned int` / `unsigned char`, so using unsigned codegen should
be possible.

Additional tests for #1308.  These are things we want to generate better
code for, so add tests that the behavior doesn't change.
2020-11-09 21:20:16 +01:00
Jesse Rosenstock
5db74b4b19 Use u16 codegen for u8 x u8 ops
In g_typeadjust, before we apply the integral promotions, we check if
both types are unsigned char.  If so, we promote to unsigned int, rather
than int, which would be chosen by the standard rules.  This is only a
performance optimization and does not affect correctness, as the flags
returned by g_typeadjust are only used for code generation, and not to
determine types of other expressions containing this one.  All unsigned
char bit-patterns are valid as both int and unsigned int and represent
the same value, so either signed or unsigned int operations can be used.
This special case part is not duplicated by ArithmeticConvert.

Partial fix for #1308.
2020-11-09 21:19:22 +01:00
Jesse Rosenstock
a686988d0e Add test cases for integral promotion of chars
Both signed and unsigned chars are promoted to int by C's evaluation
rules.  It is more efficient to use unsigned operations when possible,
however.  These tests will help test the correctness of optimizations
doing that.  See #1308.
2020-10-29 13:54:37 +01:00
Jesse Rosenstock
81550ca1ee CS_MergeLabels: Keep labels referenced by data
Partial fix for ICE in #1211.  This may fix enough to allow #1049 to be
fixed.

When merging labels, keep the first label with a ref that has no JumpTo;
this is a data segment label, used by computed gotos.

The real fix is to track and rewrite labels in data, but this is more
involved.
2020-10-08 12:11:03 +02:00
Jesse Rosenstock
b931e65811 Fix ICE for bit-fields with typedef
Fixes #1267

Avoid ICE, but treat plain int bit-fields declared via typedef as
signed rather than unsigned.  It is more efficient to treat them
as unsigned, but this requires distinguishing int from signed int,
and this is curently not done.
2020-10-03 15:04:31 +02:00
mrdudz
97a1093ee0 test related to issue #1222 2020-09-24 12:23:18 +02:00
mrdudz
a86644eff1 test related to issue #1221 2020-09-24 00:08:36 +02:00
mrdudz
b3491e3d9a test related to issue #1244 2020-09-23 23:57:36 +02:00
mrdudz
46ebb15c76 test related to issue #1245 2020-09-23 23:57:25 +02:00
Jesse Rosenstock
4e4e4c2d21 Allow char bit-fields
These are not required to be supported (only int, signed int, and
unsigned int are required), but most compilers support it.

https://port70.net/~nsz/c/c89/c89-draft.html#3.5.2.1
https://port70.net/~nsz/c/c89/c89-draft.html#A.6.5.8

For consistency with other integral types, plain `char` bit-fields
are unsigned, regardless of the `--signed-chars` option.

Fixes #1047
2020-09-08 14:24:04 +02:00
Jesse Rosenstock
9a0e4a35e1 Fix enum bit-field ICE #1244
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.
2020-09-07 11:21:23 +02:00
acqn
504aee3835
Merge branch 'master' into StaticConst 2020-08-27 06:27:23 +08:00
mrdudz
c1a514c0f8 added test related to issue #1201 2020-08-26 23:20:28 +02:00
Oliver Schmidt
c658acbf85 Avoid cl65 in tests.
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
2020-08-26 20:39:34 +02:00
acqn
0486d28abc Fixed Issue #327. 2020-08-22 13:44:18 +02:00
acqn
1abb9da2b2 Moved bug250.c to test/val as it is fixed. 2020-08-26 09:40:32 +08:00
mrdudz
e6b8f4d715 move/fix bug264.c as suggested in issue #1122 2020-08-19 22:25:18 +02:00
mrdudz
0690a12ad2 change "the cc65 authors" to "The cc65 Authors" as per jmrs request 2020-08-18 22:41:42 +02:00
mrdudz
ab89c168de replace "Copyright 2020 Google LLC" by "Copyright 2020 the cc65 authors" 2020-08-18 17:47:35 +02:00
Jesse Rosenstock
ff535b8e1a Treat signed int bit-fields as signed
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
2020-08-18 12:23:20 +02:00
mrdudz
cf41fccc0a added test related to issue #1143 2020-08-18 00:40:29 +02:00
Bob Andrews
531de44c95
Merge pull request #1193 from jmr/bitfield-union-bug
Add test of union of bit-field from mailing list
2020-08-17 14:33:51 +02:00
Jesse Rosenstock
6db93d58cf Add test of union of bit-field from mailing list
https://sourceforge.net/p/cc65/mailman/message/36152700/

This currently works, but add a test to prevent future regressions.
2020-08-17 09:54:31 +02:00
Jesse Rosenstock
1cf9404c19 Support C2X _Static_assert(expr) syntax
This makes the message in _Static_assert(expr, message) optional.

Fixes #1188.
2020-08-16 11:38:20 +02:00
Jesse Rosenstock
c4698dfd07 Use C89 semantics for integer conversions
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
2020-08-15 19:14:31 +02:00
mrdudz
f0e4053a0d added test related to issue #1178 2020-08-14 19:58:58 +02:00
acqn
1d28e8e3de Improved test case for Issue #191. 2020-08-14 18:33:54 +02:00
mrdudz
dc83eb15af added test related to issue #1181 2020-08-14 16:12:17 +02:00
Jesse Rosenstock
633cd17a3e Add enum size test case for #1050 2020-08-02 01:18:28 +02:00
Jesse Rosenstock
847982c6bf Handle bit-field test after shift/mask
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
2020-07-31 19:33:28 +02:00
Jesse Rosenstock
3df6c383c0 Add support for static_assert
Add C11's _Static_assert and static_assert macro.

This is like #error, but is handled at a later stage
of translation, so it is possible to check sizes of
types, values of enums, etc.

https://en.cppreference.com/w/c/language/_Static_assert
https://port70.net/~nsz/c/c11/n1570.html#6.7.10
2020-07-30 19:17:11 +02:00
Jesse Rosenstock
2d5fd0fc63 Use char ops if possible for bit-field loads
Set CF_FORCECHAR and change type to char once we have
shifted into a char.

This saves some unnecessary ldx #0 instructions.
2020-07-30 14:59:23 +02:00
Jesse Rosenstock
74dda01919 Add test that plain int bitfields are unsigned
We want to make sure this doesn't change when #1095 is fixed;
unsigned is much more efficient.
2020-07-29 16:43:17 +02:00
mrdudz
98b2d43c2b added tests related to pr #1110 2020-07-22 15:52:04 +02:00
mrdudz
6abf24e25e move test for issue #1077 to test/val 2020-07-22 15:12:02 +02:00
mrdudz
eb094ecf6a remove ifdef magic 2020-07-22 00:21:23 +02:00
mrdudz
4a9c5ff63b use uint16_t instead of magic ifdefs, leaving support for bit type in there incase we support it some day 2020-07-22 00:09:48 +02:00
Brad Smith
041f981960
rand() use XOR to break up unwanted pair correlation (#1107)
* 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
2020-07-21 23:38:18 +02:00
mrdudz
9e43c0a569 added a test related to pr#1102 - we can now return structs by value when they are max. 4 bytes 2020-07-21 21:04:41 +02:00
mrdudz
145084c41c move test for issue #1075 to test/var 2020-07-21 20:02:51 +02:00
mrdudz
a0c80a8c72 move (now working) tests to test/val 2020-07-21 19:24:39 +02:00
mrdudz
e4fc7a0fec reworked pptest3 into an exectutable test and moved to test/val 2020-07-21 15:30:35 +02:00
mrdudz
010ed6d729 reworked pptest1/4/5 into executable tests and moved to test/val 2020-07-21 14:58:15 +02:00
Greg King
517df130cc Made a regression test increment a variable after, instead of before, using it.
That change allows the initial value of zero to be tested.
2020-07-20 17:16:11 -04:00
mrdudz
5a9d76ad52 added test for issue #1108 2020-07-20 15:50:11 +02:00
mrdudz
a4f1e37f0c increase the maximum amount of cycles, else the shift test will fail 2020-07-13 21:26:31 +02:00
mrdudz
5ad365c5df some tweaks to the moved tests to make them more suitable for automatic testing 2020-07-13 21:26:07 +02:00
mrdudz
882194c221 move a bunch of tests from testcode/lib to test/val (and a failing one to test/todo) 2020-07-13 21:25:13 +02:00
Oliver Schmidt
bcb8b49907 Removed executable bit. 2020-07-12 23:11:43 +02:00
Jesse Rosenstock
df97570471 Set .NOTPARALLEL in test/misc and test/val
The cl65 intermediate files stomp each other in
these directories.
2020-07-10 13:08:19 +02:00
mrdudz
4b8b15a07a tests for issue #169 2020-07-09 16:05:57 +02:00
mrdudz
93f0df58e5 test related to issue #1071 2020-07-09 15:57:51 +02:00
Jesse Rosenstock
359da1ae76 Update bit-field tests after #1058 merge 2020-07-08 17:20:15 +02:00
Jesse Rosenstock
8449c9eaa0 Add zlib license text 2020-07-08 17:20:15 +02:00
Jesse Rosenstock
532e6b2554 Add copyright notice 2020-07-08 17:20:15 +02:00
Jesse Rosenstock
6f85ee9d95 Add another test for bit-field unit overlap
Test when there is another field after bit-fields with
allocation unit overlap.
2020-07-08 17:20:15 +02:00
Jesse Rosenstock
2f456ce4e2 Add comment explaining four_bits_with_int 2020-07-08 17:20:15 +02:00
Jesse Rosenstock
8a331ee7ec Print to stdout instead of stderr
Print number of failures.

This makes it consistent with the other val/ tests.
2020-07-08 17:20:15 +02:00
Jesse Rosenstock
a70ac6be30 Add test of bit-field packing for #1054 and #1055 2020-07-08 17:20:15 +02:00
mrdudz
6e6ce4e5ee added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
acqn
e9307ce58e Moved test/ref/cc65141011.c to test/val/cc65141011.c. 2020-06-22 23:23:39 +02:00
IrgendwerA8
08705a3fdc Changes resulting from 2nd code review 2020-02-03 20:45:09 +01:00
IrgendwerA8
ce80624f62 ctype size optimization 2020-02-03 20:45:09 +01:00
Greg King
a0db846a97 Allowed old-style (K and R) function declarations to be fastcall.
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).
2019-07-22 09:26:23 -04:00