Commit graph

35 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 cb983fac44 Rip out the built-in preprocessor from cemcom.ansi, now it's no longer used. 2018-09-02 12:50:50 +02:00
David Given f8fc5bc3d8 Implement single-line C++-style comments.
Fixes: #118
2018-09-02 12:14:59 +02:00
David Given 788f439a48 Run files through clang-format before editing. 2018-09-02 11:16:06 +02:00
George Koehler ca4bd38206 Delete old "assert.h" files; use libc <assert.h>.
Edit build.lua for programs losing their private assert.h, so they
depend on a list of .h files excluding assert.h.

Remove modules/src/assert; it would be a dependency of cpp.ansi but we
didn't build it, so cpp.ansi uses the libc assert.

I hope that libc <assert.h> can better report failed assertions.  Some
old "assert.h" files didn't report the expression.  Some reported a
literal "x", because traditional C expanded the macro parameter x in
"x", but ANSI C89 doesn't expand macro parameters in string literals.
2017-11-09 22:22:13 -05: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 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
ceriel 8636e9d10a Changed Header into Id 1994-06-27 08:03:14 +00:00
ceriel 1ad085cfb8 Also skip lint comments in skip_block() 1993-06-09 09:40:54 +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
ceriel b503d85d23 If NOPP is defined, do not do trigraph translation; cpp does it 1991-08-09 13:57:13 +00:00
ceriel 9f43986877 ANSI requires separate name space for labels, and made to use idf module 1991-06-19 16:12:56 +00:00
eck 7536a1f510 fixed two preprocessing bugs 1990-11-13 16:50:55 +00:00
eck 5ed44e3432 fixed error with # && ##-operators in non function-like macro's
pass printable garbage characters on to parser
1990-09-13 15:12:13 +00:00
eck 7f5abdd670 fixed int to unsigned conversions, declarations, pp-list initialization 1990-07-13 10:18:27 +00:00
eck dc12b2fa3d warn about ptrdiff_t passed as long on 2-4 machines 1990-04-25 15:09:51 +00:00
eck 84b8c8a6ca improved volatiles, added warning for possibly nested comments 1990-04-02 15:57:51 +00:00
eck d7d56d2cbb fixed bug with 0L; don't give warning on char x[3] = "abc" 1990-02-09 10:35:44 +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
ceriel a1f5834052 use normal C compiler 1989-12-19 11:07:03 +00:00
eck bdb0b550f7 U-flag was not handled properly 1989-12-12 14:59:59 +00:00
eck b3a142e244 fixed null-pointer constants and SkipToNewLine() 1989-12-12 12:52:03 +00:00
eck 96da16ce33 fixed bugs, added dynamic buffer allocation to preprocessor 1989-11-22 13:58:36 +00:00
ceriel 67f9f2a74f many little changes: removed some lint complaints; max_int and max_unsigned
are now constants if NOCROSS is defined; added lexstrict and expr_strict,
and changed calls where needed
1989-11-08 16:52:34 +00:00
ceriel 0f8516f861 use more simple hashing algorithm, made namelist generation dependant on a #define 1989-10-26 16:16:35 +00:00
ceriel 4a5a463e44 improved handling of , (comma) operator and some more Minix squeezing 1989-10-23 13:50:27 +00:00
ceriel e4857c2446 many minor modifications (it still will not fit on Minix!) 1989-10-19 14:53:25 +00:00
eck 8ff400fd0f squeezing for MINIX 1989-10-18 13:12:31 +00:00
eck fd259c398c fltcstoper.c addded to Repository 1989-10-13 11:04:42 +00:00
ceriel 10b58a8520 The InputLevel variable only exists when NOPP is not defined 1989-10-12 14:22:35 +00:00
eck 4bde31f78a minor changes concerning void and pre-processor 1989-09-29 16:20:38 +00:00
eck fa4e6eecb4 lots and lots of changes & improvements 1989-09-19 16:13:23 +00:00
ceriel 0bc88b77b2 fixed several problems:
- hex numbers and floating point numbers were wrong
- grammar was wrong; did not accept correct ANSI C
- prototype updates did not work
- float parameters to routines without prototype were not upgraded to double
- the dot operator no longer requires lvalue as left-hand-side
1989-02-07 13:16:02 +00:00
ceriel 926da49d39 Initial revision 1989-02-07 11:04:05 +00:00