Commit graph

62 commits

Author SHA1 Message Date
George Koehler 59b3c10563 Use (arith) 1 << ... when getting the sign bit.
This prevents an overflow reported by @hexcoder- in
https://github.com/davidgiven/ack/issues/56

lang/cem/cpp.ansi/LLlex.c used a plain 1 << ... and caused an overflow
on machines where sizeof(int) < sizeof(long).  Using 1L << ... would
work for now but might fail later if arith became long long.

C doesn't specify whether negative integers use 2's complement or some
other format.  Therefore, (arith) 1 << ... has an undefined value.  It
should still work because the value is some integer where the sign bit
is set and all other bits are clear.

(unsigned arith) 1 << ... would also get the sign bit, but casting it
from unsigned back to signed would make the same undefined value.

(arith) -1 << ... would assume 2's complement.
2017-10-29 17:45:10 -04:00
George Koehler 038fb6fb55 Get correct sign of a MOD b when (a > 0) and (b < 0).
Reported by me in https://github.com/davidgiven/ack/issues/60

This doesn't change DIV.  Right now a DIV b does floor division and
a MOD b has the sign of b.  This is the same as Lua, Python, Ruby,
Tcl; but is different from other Modula-2 implementations.
2017-10-28 19:55:06 -04:00
George Koehler 649410bb27 Always use unsigned long.
Traditional C compilers had long but not unsigned long.  I now assume
that everyone can compile unsigned long.  Remove macro UNSIGNED_ARITH
and act like it is always defined.  The type `unsigned arith` works
because arith is a macro for long.
2017-10-28 17:56:20 -04:00
David Given fd91851005 Add enough return types to the K&R C that the ACK builds (on Linux) using clang
now.
2016-11-10 22:04:18 +01:00
David Given f6c43b95ef Modula-2 now works.
--HG--
branch : dtrg-buildsystem
rename : lang/pc/build.mk => lang/m2/build.mk
rename : lang/pc/libpc/build.mk => lang/m2/comp/build.mk
rename : lang/pc/libpc/build.mk => lang/m2/libm2/build.mk
2013-05-14 22:24:38 +01:00
ceriel efacd02ffd Added LONGCARD as a local extension 1996-08-14 07:42:40 +00:00
ceriel 1db6a3029b Header --> Id 1994-06-24 14:02:31 +00:00
ceriel 5a53ba3f50 Several minor mods: simplifications and identifier name changes 1991-03-18 16:30:49 +00:00
ceriel 852601d0b5 minor mods 1991-03-14 13:16:32 +00:00
ceriel 86bc055fa1 Corrected error on NOCROSS 1991-03-14 09:31:32 +00:00
ceriel f7504dbd4b Cleaned up a bit more 1991-03-13 17:26:07 +00:00
ceriel 52842cd09a Cleaned up a bit 1991-03-13 13:49:56 +00:00
ceriel 0a517b9256 Changes to make node structure smaller, and cleaned up a bit 1991-03-12 16:52:00 +00:00
ceriel 76d79cf17a Added macro's for long selections 1991-03-06 10:52:34 +00:00
ceriel 109a357e95 Fix: DIV and MOD on negative args 1990-07-16 09:05:19 +00:00
ceriel c3b3faf7a4 Added support for constant floating point expressions 1989-12-19 09:40:25 +00:00
ceriel d277946286 changed name of some identifiers to more accurately represent their
meaning, and fixed a problem with sometimes not detecting overflow in
constants
1989-08-08 09:11:32 +00:00
ceriel f9b6acf1dc New version with different parameter passing mechanism and some
minor fixes
1989-03-20 13:32:06 +00:00
ceriel ce0ec1c143 delinted somewhat 1988-10-13 15:43:23 +00:00
ceriel 905c5a349f fix: >= and <= were wrong in constant expressions 1988-08-05 11:22:39 +00:00
ceriel 2bbecf2416 better argument checking of standard functions 1988-04-26 10:14:01 +00:00
ceriel 0976dfa3b9 too many changes: some cosmetic; some for 2/4; some for added options 1988-03-21 17:06:20 +00:00
ceriel 78926a5a84 fix typo and parameters of overflow 1988-03-08 10:35:53 +00:00
ceriel ad2d61154b fixed some minor problems 1988-01-15 16:55:01 +00:00
ceriel a61d36ff49 fixes and squeezing 1987-12-02 10:41:38 +00:00
ceriel 896fec3fc5 version with better overflow checking 1987-11-26 14:15:24 +00:00
ceriel b668810351 sets now allowed for all subranges 1987-10-28 16:03:56 +00:00
ceriel 688567a532 fix in reference counts for sets 1987-10-20 13:32:18 +00:00
ceriel 503edee161 New version, with an option for strict Modula-2, and
warnings for unused or uninitialized variables
1987-10-19 11:28:37 +00:00
ceriel fd817d4dbc Minor adaptions in order to reduce the size 1987-09-23 16:39:43 +00:00
ceriel 0e397f09f3 many changes; some cosmetic; coercions now explicit in tree 1987-07-30 13:37:39 +00:00
ceriel 6614384f3c fixes, changes to make smaller on PDP 1987-07-21 13:54:33 +00:00
ceriel 746f94368d fixes, added 's' option 1987-06-23 17:12:25 +00:00
ceriel c839c01680 some fixes, and changed priority of unary minus 1987-06-18 15:46:08 +00:00
ceriel bb9b16ab50 fixes, added some standard functions to handle LONGREAL, LONGINT 1987-05-27 10:16:03 +00:00
ceriel ed2d6ab75b some changes to make smaller 1987-05-21 09:37:28 +00:00
ceriel 6fc7d0f866 bug fix in constant set computations 1987-05-13 13:04:28 +00:00
ceriel 48acbe27bb fixed a minor bug in cstoper.c: computation of mach_long_sign was wrong 1987-05-12 11:15:55 +00:00
ceriel fbc0415761 make to work on sun, added copyright, etc 1987-04-29 10:22:07 +00:00
ceriel a0c21bf820 many bug fixes, and added flexibility in alignments 1986-11-28 11:59:08 +00:00
ceriel 9d0ee46068 Trying to check more of an expression, giving some more sophisticated error messages,and be less wasteful with space for subranges 1986-11-17 11:41:28 +00:00
ceriel 9291d87dab Several bug fixes 1986-11-05 14:33:00 +00:00
ceriel 3030eb8cae newer version 1986-10-06 20:36:30 +00:00
ceriel a0db745586 newer version with bug fixes 1986-08-26 14:33:24 +00:00
ceriel d5a95fcac0 Some bug fixes 1986-07-14 15:00:08 +00:00
ceriel 965e75761d newer version 1986-07-08 14:59:02 +00:00
ceriel bcfca75b56 newer version 1986-06-26 09:39:36 +00:00
ceriel ec528b797e newer version 1986-06-10 13:18:52 +00:00
ceriel caf99ea472 newer version 1986-06-06 02:22:09 +00:00
ceriel 9e0ab0029b first, almost complete, version 1986-06-04 09:01:48 +00:00