aboutsummaryrefslogtreecommitdiff
path: root/tccpp.c
Commit message (Collapse)AuthorAgeFilesLines
* tccgen: fix inline_functions double free fixgrischka2016-11-111-10/+15
|
* tccgen: inline_functions double free fixgrischka2016-11-111-2/+1
| | | | | | Fix double free of the inline function token_string which could happen when an error/longjmp occurred while compiling the inline function.
* tccpp_new/delete and other cleanupsgrischka2016-10-171-4/+7
|
* tccpp : "tcc -E -P" : suppress empty linesgrischka2016-10-091-7/+13
| | | | | | | | | Also: - regenerate all tests/pp/*.expect with gcc - test "insert one space" feature - test "0x1E-1" in asm mode case - PARSE_FLAG_SPACES: ignore \f\v\r better - tcc.h: move some things
* tccpp: no cache for include if #elif seengrischka2016-10-041-8/+9
| | | | | | | | #ifndef guards are cached, however after #elif on the same level, the file must be re-read. Also: preprocess asm as such even when there is no assembler (arm).
* tccpp: parse_line_comment: fix possible buffer overrungrischka2016-10-011-3/+3
|
* tccpp: allow "0x1e+1" in asmgrischka2016-10-011-9/+13
|
* tccpp: token ## pasting: preserve parts if pasting failsgrischka2016-10-011-10/+12
| | | | | | | | | for example #define LBL(name) _ ## name ## : LBL(main) will give two tokens '_main' and ':' and the warning
* Revert "-fnormalize-inc-dirs"grischka2016-10-011-1/+0
| | | | | | | Too much code. gcc 3.x doesn't have that either. This reverts commit 41785a0bf9d505a3647a10ddc330417f52fd4528. This reverts commit 21665f433890e2038626f0b3123b189a62a67dc9.
* tcc -E: add one space in cases: tiny solutiongrischka2016-10-011-52/+20
| | | | | | replaces f5f82abc99424c4ece836000934fcf57a867c635 Also: fix tcc flags in Makefile, fix tcc -E
* tccpp: cleanupgrischka2016-10-011-69/+101
| | | | | | | | | | | | | | | | - "utf8 in identifiers" from 936819a1b90f2618bb3f86730189cf2895948ba0 - CValue: remove member str.data_allocated - make tiny allocator private to tccpp - allocate macro_stack objects on heap because otherwise it could crash after error/setjmp in preprocess_delete():end_macro() - mov "TinyAlloc" defs to tccpp.c - define_push: take int* str again
* libtcc: cleanup @listfilegrischka2016-10-011-15/+0
| | | | | | | | | Also: - allow more than one item per line - respect "quoted items" and escaped quotes \" (also for LIBTCCAPI tcc_setoptions) - cleanup some copy & paste
* tccpp: #pragma once: make it workgrischka2016-10-011-35/+23
| | | | | | | | | | | after several "fixes" and "improvements" b3782c3cf5e66f74207303c381a305daabccdb12 5fb57bead41cd3a84f0aa3f98d00b5fe5de25a08 feature did not work at all - Use 'once' flag, not 'ifndef_macro' - Ignore filename letter case on _WIN32 - Increment global pp_once for each compilation
* tccpp: restore -D symbols for multiple sourcesgrischka2016-10-011-14/+16
| | | | | | | | | | | | | | | ... also for built-in defines The case: $ tcc -D FOO a.c b.c with // a.c #undef FOO // b.c #ifndef FOO # error -D FOO has been lost #endif
* Rein in unintended external functions.Jean-Claude Beaudoin2016-09-251-2/+2
|
* Remove vestiges of earlier type mergerDavid Mertens2016-08-161-4/+1
|
* win64: fix va_arggrischka2016-07-101-3/+0
| | | | | | | | | | | fixes 5c35ba66c5ade4713bbd9c005e66889f6d7db293 Implementation was consistent within tcc but incompatible with the ABI (for example library functions vprintf etc) Also: - tccpp.c/get_tok_str() : avoid "unknown format "%llu" warning - x86_64_gen.c/gen_vla_alloc() : fix vstack leak
* Redo "fix line number in macro redefined message"grischka2016-05-251-5/+2
| | | | | | Smaller change to fix more cases This reverts commit 0f36f60faa05da7e250a4b4eebd4b534e8a2b537.
* fix line number in macro redefined messageseyko2016-05-161-2/+5
|
* tcc -E -P10 : output all numbers as decimalsgrischka2016-05-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This may be used to preprocess Fabrice Bellards initial revision in this repository to demonstrate its capability to compile and run itself (on i386 32-bit linux or windows). Initial revision: 27f6e16bae9d0f73acec07f61aea696ab5adc680 Also needed: * an empty stdio.h * a wrapper named tc.c with void expr(void); void decl(int); void next(void); #include "tcc.c" * an hello.c such as int main() { printf("Hello World\n"); return 0; } All files with unix LF only lines. Then ... * preprocess the source $ tcc -E -P10 -I. tcc.c -o tc1.c * compile the compiler $ tcc -w -I. tc.c -o tc -ldl * run it to compile and run itself to compile and run itself to compile and run itself to compile and run hello.c $ ./tc tc1.c tc1.c tc1.c hello.c --> Hello World! ------------------------------------------------------ * On i386 windows this may be added to the tc.c wrapper #ifdef _WIN32 #include <windows.h> void *dlsym(int x, const char *func) { if (0 == strcmp(func, "dlsym")) return &dlsym; return GetProcAddress(LoadLibrary("msvcrt"), func); } #endif
* Insert spaces between certain tokens when tcc is invoked with -E.Edmund Grimley Evans2016-05-091-1/+53
| | | | | | Insert a space when it is required to prevent mistokenisation of the output, and also in a few cases where it is not strictly required, imitating GCC's behaviour.
* TOK_PPNUM in asm (Edmund Grimley Evans version)seyko2016-05-081-0/+1
|
* tccpp: cleanup options -dD -dM, remove -Cgrischka2016-05-051-202/+180
| | | | | | | The lexer is for reading files, not for writing. Also : - macro_is_equal(): avoid crash if redefining __FILE__
* Revert 78e4ee5.Edmund Grimley Evans2016-05-041-34/+9
|
* Revert 3283c26 and a1c1390 in tccpp.c.Edmund Grimley Evans2016-05-041-46/+4
|
* PP_NUM in ASM modeseyko2016-05-041-9/+34
| | | | | | oxe+1 is parsed as 0xe +1 if (parse_flags & PARSE_FLAG_ASM_FILE) Helps to compile a code: __asm__("mov $0xe" "+1", "%eax\n")
* clearing "output space after TOK_PPNUM ..."seyko2016-05-011-23/+20
|
* output space after TOK_PPNUM which followed by '+' or '-'seyko2016-05-011-4/+49
| | | | | | * correct -E output for the case ++ + ++ concatenation do this only for expanded from macro string and only when tcc_state->output_type == TCC_OUTPUT_PREPROCESS
* tccpp: macro subst fixgrischka2016-04-291-4/+4
| | | | | | | | | #define Y(x) Z(x) #define X Y return X(X(1)); was : return Z(Y(1)); now : return Z(Z(1));
* fix for the "Reduce allocations overhead"seyko2016-04-221-1/+1
| | | | Now no trap when compiling tccboot
* .rept asm directiveseyko2016-04-221-1/+2
| | | | | and '.' alone is a token now in *.S (not an identifier) representing a current position in the code (PC).
* Source and destination overlap in memcpy, cstr_cat (tccpp.c:322)seyko2016-04-221-1/+1
| | | | This code is from "Improve hash performance"
* Reduce allocations overheadVlad Vissoultchev2016-04-171-7/+177
| | | | | | | | | - uses new `TinyAlloc`-ators for small `TokenSym`, `CString` and `TokenString` instances - conditional `TAL_DEBUG` for mem leaks and double frees detection - on `TAL_DEBUG` collects allocation origin (file + line) - conditional `TAL_INFO` for allocators stats (in release mode too) - chain a new allocator twice current capacity on buffer exhaustion
* Improve hash performanceVlad Vissoultchev2016-04-171-78/+83
| | | | | | | | | | | | - better `TOK_HASH_FUNC` - increases `hash_ident` initial size to 16k (from 8k) - `cstr_cat` uses single `realloc` + `memcpy` - `cstr_cat` can append terminating zero - `tok_str_realloc` initial size to 16 (from 8) - `parse_define` uses static `tokstr_buf` - `next` uses static `tokstr_buf` - fixes two latent bugs (wrong deallocations in libtcc.c:482 and tccpp.c:2987)
* simplify -C printingseyko2016-04-171-112/+29
| | | | | | | | | | parse_print_line_comment() and parse_print_comment() are combined and made more simply: * don't worry about speed with -E option * don't handle straya in comments Do we need to handle strays in regular parse_line_comment() and parse_comment() ?
* preprocessor oprtion -C (keep comments)seyko2016-04-151-31/+169
| | | | | This is done by impression of the pcc -C option. Usual execution path and speed are not changed.
* fix preprocessing *.S with ` ' chars in #commentsseyko2016-04-141-1/+5
| | | | | with a test program. Problem detected when trying to compile linux-2.4.37.9 with tcc.
* fix for thev "#pragna once" guardseyko2016-04-141-1/+1
| | | | | gcc 3.4.6 don't understand "#if PATHCMP==stricmp" where "#define PATHCMP stricmp"
* Move utility functions `trimfront/back` to tccpp.cVlad Vissoultchev2016-04-131-0/+15
| | | | These are used in `libtcc.c` now and cannot remain in `tccpe.c`
* Better pragma once guardVlad Vissoultchev2016-04-131-4/+8
| | | | This takes care of case-insensitive filenames (like on win32)
* tccpp.c: Guard against ppfp being NULLVlad Vissoultchev2016-04-131-17/+16
| | | | Missed these in e946eb2a4109e0de5f8514457f851897a4824c3e
* correct version of "Identifiers can start and/or contain"seyko2016-04-131-2/+12
| | | | | | | A problem was in TOK_ASMDIR_text: - sprintf(sname, ".%s", get_tok_str(tok1, NULL)); + sprintf(sname, "%s", get_tok_str(tok1, NULL)); When tok1 is '.text', then sname is '..text'
* Fix pragma once guardseyko2016-04-131-2/+5
| | | | | | | | | | | | | | From: Vlad Vissoultchev Date: Mon, 11 Apr 2016 01:26:32 +0300 Subject: Fix pragma once guard when compiling multiple source files When compiling multiple source files directly to executable cached include files guard was incorrectly checked for TOK_once in ifndef_macro member. If two source files included the same header guarded by pragma once, then the second one erroneously skipped it as `cached_includes` is not cleared on second `tcc_compile`
* revert of the 'Identifiers can start and/or contain'seyko2016-04-131-12/+2
| | | | | | | | When tccboot kernels compiles with 'Identifiers can start and/or', this kernel don't start. It is hard to find what is wrong. PS: there was no test for identifiers in *.S with '.'
* Implement -dM preprocessor option as in gccVlad Vissoultchev2016-04-061-5/+5
| | | | | | There was already support for -dD option but in contrast -dM dumps only `#define` directives w/o actual preprocessor output. The original -dD output differs from gcc output by additional comment in front of `#define`s so this quirk is left for -dM as well.
* cleaning "Identifiers can start and/or contain"seyko2016-04-051-4/+6
| | | | more logical algorithm of the isidnum_table[] changing
* compilation speed of the tccboot correctionseyko2016-04-051-0/+4
| | | | | | | we use gnu extension "case 0x80 ... 0xFF" for tcc & gcc and perform test if(c & 0x80) for other compilers
* utf8 in identifiersseyko2016-04-051-1/+13
| | | | | | | | | | | | | | made like in pcc (pcc.ludd.ltu.se/ftp/pub/pcc-docs/pcc-utf8-ver3.pdf) We treat all chars with high bit set as alphabetic. This allow code like #include <stdio.h> int Lefèvre=2; int main() { printf("Lefèvre=%d\n",Lefèvre); return 0; }
* optimization of the previous patchseyko2016-04-051-4/+6
| | | | | compilation speed of the tccboot restored (patch remove testing of the parse_flags in loop)
* Identifiers can start and/or contain '.' in *.Sseyko2016-04-051-3/+9
| | | | | | | | | | | | | | | | | modified version of the old one which don't allow '.' in #define Identifiers. This allow correctly preprocess the following code in *.S #define SRC(y...) \ 9999: y; \ .section __ex_table, "a"; \ .long 9999b, 6001f ; \ // .previous SRC(1: movw (%esi), %bx) 6001: A test included.