1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-30 04:29:26 +00:00
cc65/test/val
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
..
add1.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
add2.c 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
add3.c added makefile and common include 2014-11-22 16:59:31 +01:00
add3a.c Removed executable bit. 2020-07-12 23:11:43 +02:00
add4.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
add5.c Added a cc65 regression test for pointer and offset addition operations. 2016-01-01 11:39:55 -05:00
and1.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
and2.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
anon-struct1.c Made a C union declaration know the sizes of anonymous struct/union members when it determines its size. 2018-05-13 18:54:45 -04:00
anon-struct2.c Made a C union declaration know the sizes of anonymous struct/union members when it determines its size. 2018-05-13 18:54:45 -04:00
assign-use1.c Fixed a bug that didn't preserve the accumulator's value when a simple 16-bit fetch-and-store is optimized. (#637) 2018-05-12 13:46:16 -04:00
atoi-test.c 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
binlit.c binlit: Add a few random leading zeros 2019-07-20 17:21:42 +02:00
bitfield.c Use char ops if possible for bit-field loads 2020-07-30 14:59:23 +02:00
bool1.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
bool3.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
bss-name-decl.c Fix regression of #pragma bss-name 2017-03-21 22:35:25 +01:00
bss-name.c Fix regression of #pragma bss-name 2017-03-21 22:35:25 +01:00
bug170.c Use C89 semantics for integer conversions 2020-08-15 19:14:31 +02:00
bug367.c Fix for multiplication optimization issue #367 2019-04-02 16:34:22 +02:00
bug735.c Testcase added. 2018-10-16 09:45:30 +02:00
bug830.c Fix for #830 supplied by UvB 2019-04-25 15:19:53 +02:00
bug895.c bug895 test: more specific description comment 2019-05-27 10:03:25 +02:00
bug975.c move (now working) tests to test/val 2020-07-21 19:24:39 +02:00
bug1050.c Add enum size test case for #1050 2020-08-02 01:18:28 +02:00
bug1071.c test related to issue #1071 2020-07-09 15:57:51 +02:00
bug1075.c move test for issue #1075 to test/var 2020-07-21 20:02:51 +02:00
bug1077.c move test for issue #1077 to test/val 2020-07-22 15:12:02 +02:00
bug1108.c Made a regression test increment a variable after, instead of before, using it. 2020-07-20 17:16:11 -04:00
bug1139.c Handle bit-field test after shift/mask 2020-07-31 19:33:28 +02:00
bug1178.c added test related to issue #1178 2020-08-14 19:58:58 +02:00
bug1181.c added test related to issue #1181 2020-08-14 16:12:17 +02:00
call1.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
casttochar.c Removed executable bit. 2020-07-12 23:11:43 +02:00
cc65091020.c removed common.h reference 2014-11-23 12:50:47 +01:00
cc65141002.c Removed executable bit. 2020-07-12 23:11:43 +02:00
cc65141011.c Removed executable bit. 2020-07-12 23:11:43 +02:00
cc65141022.c Removed executable bit. 2020-07-12 23:11:43 +02:00
cc65150311.c patch from Uz that makes some illegal operations on pointers error out 2015-07-10 14:27:49 +02:00
common.h added makefile and common include 2014-11-22 17:02:46 +01:00
compare1.c Changed most "backticks" (grave accents) into apostrophes. 2019-01-05 14:57:12 -05:00
compare2.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
compare3.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
compare4.c 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
compare5.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
compare6.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
compare7.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
compare8.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
compare9.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
compare10.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
computedgoto.c again, some TABs slipped into the code... 2019-04-30 18:21:13 +02:00
cq4.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq9.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq22.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq25.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq26.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq61.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq71.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq72.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq81.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq84.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq85.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq86.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq88.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq241.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq243.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq244.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq626.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq714.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq714b.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq715.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq757.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
cq7813.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
div-char-char.c tests for issue #169 2020-07-09 16:05:57 +02:00
div-common.h tests for issue #169 2020-07-09 16:05:57 +02:00
div-int-int.c tests for issue #169 2020-07-09 16:05:57 +02:00
div-long-long.c tests for issue #169 2020-07-09 16:05:57 +02:00
duffs-device.c Added Duff's Device to tests. 2016-08-15 11:26:03 -07:00
fields.c move (now working) tests to test/val 2020-07-21 19:24:39 +02:00
for.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
jmp-callax.c again, some TABs slipped into the code... 2019-04-30 18:21:13 +02:00
lib_common_atoi.c Added further optimizations and unit tests. 2017-03-05 02:09:12 +01:00
lib_common_ctype.c Changes resulting from 2nd code review 2020-02-03 20:45:09 +01:00
lib_common_memmove.c Removed workaround. 2017-04-04 15:45:24 +02:00
lib_common_mulxx.c Code review adaptations, removed "cc65_" prefix from functions 2019-03-29 22:53:04 +01:00
lib_common_strcat.c Removed workaround. 2017-04-04 15:51:00 +02:00
lib_common_strchr.c Added further optimizations and unit tests. 2017-03-05 02:09:12 +01:00
lib_common_strcspn.c Removed workaround. 2017-04-04 15:52:01 +02:00
lib_common_strncat.c Removed workaround. 2017-04-04 15:52:37 +02:00
lib_common_strol.c Added further optimizations and unit tests. 2017-03-05 02:09:12 +01:00
lib_common_strrchr.c Added further optimizations and unit tests. 2017-03-05 02:09:12 +01:00
lib_common_strspn.c Removed workaround. 2017-04-04 15:53:14 +02:00
lib_common_strtoul.c Added further optimizations and unit tests. 2017-03-05 02:09:12 +01:00
lz4.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
Makefile increase the maximum amount of cycles, else the shift test will fail 2020-07-13 21:26:31 +02:00
mult1.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
nestfor.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
or1.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
plain-int-bitfield.c Add test that plain int bitfields are unsigned 2020-07-29 16:43:17 +02:00
pointed-array.c Removed some trailing whitespace; and, expanded a tab. 2015-07-01 10:09:11 -04:00
pointer1.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
postdec-8-8.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
postdec-8-16.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
postdec-16-8.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
postdec-16-16.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
postinc-8-8.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
postinc-8-16.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
postinc-16-8.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
postinc-16-16.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
postincdec.c remote TABs in doc/ and test/ 2019-02-12 22:50:49 +01:00
pptest1.c reworked pptest1/4/5 into executable tests and moved to test/val 2020-07-21 14:58:15 +02:00
pptest3.c reworked pptest3 into an exectutable test and moved to test/val 2020-07-21 15:30:35 +02:00
pptest4.c reworked pptest1/4/5 into executable tests and moved to test/val 2020-07-21 14:58:15 +02:00
pptest5.c reworked pptest1/4/5 into executable tests and moved to test/val 2020-07-21 14:58:15 +02:00
pr1102.c 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
pr1110a.c added tests related to pr #1110 2020-07-22 15:52:04 +02:00
predec-8-8.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
predec-8-16.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
predec-16-8.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
predec-16-16.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
preinc-8-8.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
preinc-8-16.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
preinc-16-8.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
preinc-16-16.c added various tests related to bug #1045 2020-06-23 00:46:12 +02:00
ptrfunc.c remove ifdef magic 2020-07-22 00:21:23 +02:00
rand.c rand() use XOR to break up unwanted pair correlation (#1107) 2020-07-21 23:38:18 +02:00
rotate1.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
rotate2.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
rotate3.c 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
rotate4.c 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
rotate5.c 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
rotate6.c 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
rotate7.c 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
rotate8.c Added a regression test program for the changes in the right-shift optimizer. 2015-12-14 11:46:30 -05:00
shift-test.c 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
signal-test.c some tweaks to the moved tests to make them more suitable for automatic testing 2020-07-13 21:26:07 +02:00
snprintf-test.c some tweaks to the moved tests to make them more suitable for automatic testing 2020-07-13 21:26:07 +02:00
static-1.c Improved test case for Issue #191. 2020-08-14 18:33:54 +02:00
static-fwd-decl.c Add regression test for #204. 2017-03-09 20:40:20 +01:00
staticassert.c Add support for static_assert 2020-07-30 19:17:11 +02:00
strncmp-test.c some tweaks to the moved tests to make them more suitable for automatic testing 2020-07-13 21:26:07 +02:00
strnicmp-test.c some tweaks to the moved tests to make them more suitable for automatic testing 2020-07-13 21:26:07 +02:00
strpbrk-test.c some tweaks to the moved tests to make them more suitable for automatic testing 2020-07-13 21:26:07 +02:00
strtol-test.c 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
strtoul-test.c 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
struct1.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
sub1.c 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
sub2.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
switch1.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00
switch2.c Updated switch statement comments. 2016-08-19 20:21:10 -07:00
time-test.c some tweaks to the moved tests to make them more suitable for automatic testing 2020-07-13 21:26:07 +02:00
time.c Increased consistency. 2018-08-02 15:45:57 +02:00
trampoline-params.c Changed empty parameter lists into (void) lists on functions with asm() statements. 2019-07-16 13:16:02 -04:00
trampoline-varargs.c Changed empty parameter lists into (void) lists on functions with asm() statements. 2019-07-16 13:16:02 -04:00
trampoline.c Changed empty parameter lists into (void) lists on functions with asm() statements. 2019-07-16 13:16:02 -04:00
unittest.h Added further optimizations and unit tests. 2017-03-05 02:09:12 +01:00
void-size1.c Made C's sizeof operator work with initialized void variables. 2017-03-12 14:41:32 -04:00
while.c Fixed the handling of "while (0) {}". 2017-04-07 09:26:58 -04:00
xor.c added tests as prepared by oliver 2014-09-25 21:38:34 +02:00