Commit graph

21 commits

Author SHA1 Message Date
George Koehler 15950f9c95 Add long long literals like 123LL to ACK C.
For now, a long long literal must have the 'LL' or 'll' suffix.  A
literal without 'LL' or 'll' acts as before: it may become unsigned
long but not long long.  (For targets where int and long have the same
size, some literals change from unsigned int to unsigned long.)

Type `arith` may be too narrow for long long values.  Add a second
type `writh` for wide arithmetic, and change some variables from arith
to writh.  This may cause bugs if I forget to use writh, or if a
conversion from writh to arith overflows.  I mark some conversions
with (arith) or (writh) casts.

 - BigPars, SmallPars: Remove SPECIAL_ARITHMETICS.  This feature
   would change arith to a different type, but can't work, because it
   would conflict with definitions of arith in both <em_arith.h> and
   <flt_arith.h>.
 - LLlex.c: Understand 'LL' or 'll' suffix.  Cut size of constant when
   it overflows writh, not only when it overflows the target machine's
   types.  (This cut might not be necessary, because we might cut it
   again later.)  When picking signed long or unsigned long, check the
   target's long type, not the compiler's arith type; the old check
   for `val >= 0` was broken where sizeof(arith) > 4.
 - LLlex.h: Change struct token's tok_ival to writh, so it can hold a
   long long literal.
 - arith.c: Adjust to VL_VALUE being writh.  Don't convert between
   float and integer at compile-time if the integer might be too wide
   for <flt_arith.h>.  Add writh2str(), because writh might be too
   wide for long2str().
 - arith.h: Remove SPECIAL_ARITHMETICS.  Declare full_mask[] here,
   not in several *.c files.  Declare writh2str().
 - ch3.c, ch3bin.c, ch3mon.c, declarator.c, statement.g: Remove
   obsolete casts.  Adjust to VL_VALUE being writh.
 - conversion.c, stab.c: Don't declare full_mask[].
 - cstoper.c: Use writh for constant operations on VL_VALUE, and for
   full_mask[].
 - declar., field.c, ival.g: Add casts.
 - dumpidf.c: Need to #include "parameters.h" before checking DEBUG.
   Use writh2str, because "%ld" might not work.
 - eval.c, eval.h: Add casts.  Use writh when writing a wide constant
   in EM.
 - expr.c: Add and remove casts.  In fill_int_expr(), make expression
   from long long literal.  In chk_cst_expr(), allow long long as
   constant expression, so the compiler may accept `case 123LL:` in a
   switch statement.
 - expr.str: Change struct value's vl_value and struct expr's VL_VALUE
   to writh, so an expression may have a long long value at compile
   time.
 - statement.g: Remove obsolete casts.
 - switch.c, switch.str: Use writh in case entries for switch
   statements, so `switch (ll) {...}` with long long ll works.
 - tokenname.c: Add ULNGLNG so LLlex.c can use it for literals.
2019-09-04 22:14:38 -04:00
carl 750a6bc684 Better ANSI C compatibility and portability:
+ Addition of function prototypes and include files.
+ Change function definitions to ANSI C style.
+ Initial support for CMake
+ Scripts to generate compiler header is now sed based.
2019-02-19 00:54:23 +08:00
David Given c1aca7dae5 First milestone of replacing the build system.
--HG--
branch : dtrg-buildsystem
rename : lang/cem/cpp.ansi/Parameters => lang/cem/cpp.ansi/parameters.h
2013-05-12 20:45:55 +01:00
George Koehler 800d4ae032 Fix cemcom.ansi for 64-bit hosts.
Hosts with sizeof(arith) == sizeof(long) == 8 need to set full_mask[1]
through full_mask[8].  Because MAXSIZE == 8, we only had full_mask[0]
through full_mask[7].  This fix declares arith full_mask[MAXSIZE + 1]
and prevents a fatal error: "array full_mask too small for this machine"
2012-09-07 15:53:13 -04:00
ceriel 8636e9d10a Changed Header into Id 1994-06-27 08:03:14 +00:00
ceriel ebdbabcedd Removed # in commands, and a small fix in ch3mon.c 1992-06-26 11:57:17 +00:00
ceriel 09a80e9e13 Fixed checking of unary '*' 1992-06-12 09:03:07 +00:00
ceriel a38be6605e Do not use '#endif/#else xxx'; it is not allowed for ANSI C 1991-12-17 13:12:22 +00:00
eck a246152240 removed crash() call: it was wrong 1990-09-14 16:39:11 +00:00
eck 81b7f67cb4 result of sizeof() is 'unsigned int' (for backward compatibility) 1990-04-23 13:33:07 +00:00
eck aa4de95f26 various bug fixes & improvements 1990-04-06 15:37:16 +00:00
eck ad7e46a324 code for '*(ip = iarr) = x' was wrong 1990-04-04 15:08:45 +00:00
eck 00876cd9df added alloction dump
shrunk some data structures
changed some ALLOCDEF's
changed setjmp to __setjmp
1990-01-10 17:33:35 +00:00
eck 8790a879c9 fixed sizeof() 1989-12-13 12:53:22 +00:00
eck b3a142e244 fixed null-pointer constants and SkipToNewLine() 1989-12-12 12:52:03 +00:00
eck 671556cfc4 improved type-checking, fixed preprocessor bug, fixed syntax bug 1989-11-27 11:37:11 +00:00
eck d50600e263 fixed unary & and indirect calls 1989-11-22 16:41:09 +00:00
eck 96da16ce33 fixed bugs, added dynamic buffer allocation to preprocessor 1989-11-22 13:58:36 +00:00
ceriel d6fa6357f2 some more Minix squeezing 1989-10-20 11:58:37 +00:00
eck 4bde31f78a minor changes concerning void and pre-processor 1989-09-29 16:20:38 +00:00
eck 00027d3893 some minor fixes, renamed ch7 stuff to ch3 1989-09-25 14:28:10 +00:00