aboutsummaryrefslogtreecommitdiff
path: root/tccpp.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* -fnormalize-inc-dirsseyko2016-04-031-0/+1
| | | | | | remove non-existent or duplicate directories from include paths if -fnormalize-inc-dirs is specified. This will help to compile current coreutils package
* reverse of the "Identifiers can start and/or contain '.'"seyko2016-04-031-2/+1
| | | | | | | | | | | | | | | | | - Identifiers can start and/or contain '.' in PARSE_FLAG_ASM_FILE - Move all GAS directives under TOK_ASMDIR prefix This patches breaks compilation of the tccboot (linux 2.4.26 kernel). A test.S which fails with this patches: #define SRC(y...) \ 9999: y; \ .section __ex_table, "a"; \ .long 9999b, 6001f<---->; \ .previous SRC(1:<>movw (%esi), %bx<------>) // 029-test.S:7: error: macro 'SRC' used with too many args
* Fix tokenization of TOK_DOTSMichael Matz2016-03-241-3/+9
| | | | | We really need to use PEEKC during tokenization so as to skip line continuations automatically.
* Identifiers can start and/or contain '.' in PARSE_FLAG_ASM_FILEVlad Vissoultchev2016-03-141-10/+8
| | | | Including labels, directives and section names
* tccpp.c: Fix failing `PPTest 03` by reverting rogue modification in ↵Vlad Vissoultchev2016-03-141-1/+1
| | | | `macro_arg_subst`
* Migrate static STRING_MAX_SIZE buffers to CString instances for large macros ↵Vlad Vissoultchev2016-03-131-14/+23
| | | | expansion
* Change the way struct CStrings are handled.Edmund Grimley Evans2015-11-261-37/+37
| | | | | | | | | A CString used to be copied into a token string, which is an int array. On a 64-bit architecture the pointers were misaligned, so ASan gave lots of warnings. On a 64-bit architecture that required memory accesses to be correctly aligned it would not work at all. The CString is now included in CValue instead.
* tccpp: allow .. in token streamgrischka2015-11-201-4/+7
| | | | | | | | | | for gas comments lonely on a line such as # .. more stuff where tcc would try to parse .. as a preprocessor directive See also: 0b3612631f49ba0c008635aaa46ecf8be2eefcf7
* tccpp: cleanup #include_nextgrischka2015-11-201-34/+45
| | | | | | | | | | | | | | | | tcc_normalize_inc_dirs: normally no problem to be absolutly gcc compatible as long as it can be done the tiny way. This reverts to the state before recent related commits and reimplements a (small) part of it to fix the reported problem. Also: Revert "parsing "..." sequence" c3975cf27c792d493e76a2058a1eaf588324053e && p[1] == '.' is not a reliable way to lookahead
* tccgen: asm_label cleanupgrischka2015-11-201-1/+9
| | | | | | | - avoid memory allocation by using its (int) token number - avoid additional function parameter by using Attribute Also: fix some strange looking error messages
* Merge the integer members of union CValue into "uint64_t i".Edmund Grimley Evans2015-11-171-5/+5
|
* TOK_INCLUDE: fix for the "normalize inc dirs"seyko2015-11-061-1/+1
| | | | A case for the absolute path: prevent an error after openening
* TOK_INCLUDE: streamlineseyko2015-11-061-12/+5
| | | | goto removed
* normalize inc dirs, symplify include_nextseyko2015-11-051-71/+16
| | | | | | | | | include dirs are prepared as in gcc - for each duplicate path keep just the first one - remove each include_path that exists in sysinclude_paths include_next streamlined by introducing inc_path_index in the BufferedFile
* tccpp.c: In TOK_GET, add comment warning about illegal cast.Edmund Grimley Evans2015-11-041-8/+11
| | | | | | Also, in tok_str_add2, use memcpy instead of the illegal cast. Unfortunately, I can't see an easy way of fixing the bug.
* tccpp.c: Define and use tok_last for checking if last token is space.Edmund Grimley Evans2015-11-041-1/+16
|
* fix for the #include_next, v4 (final)seyko2015-10-201-19/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This version looks rigth. Comparing to the original algorithm: 1) Loop breaking. We remember a start point after wich we can try next path. Do not search include stack after this. 2) But compare next file patch with the start point. Skip if it the same. Remove "./" before comparing. PS: a problems with compaling a coreutils-8.24.51-8802e remain. There are errors messages like: src/chgrp src/chown-core.c:42: multiple definition of `make_timespec' src/chgrp.c:42: first defined here A problem is in the lib/config.h #define _GL_INLINE_ extern inline // gcc #define _GL_INLINE_ inline // tcc A long description from the lib/config.h * suppress extern inline with HP-UX cc, as it appears to be broken * suppress extern inline with Sun C in standards-conformance mode * suppress extern inline on configurations that mistakenly use 'static inline' to implement functions or macros in standard C headers like <ctype.h>. GCC and Clang are excluded from this list. Why not tcc?
* fix for the #include_next, v3seyko2015-10-191-14/+4
| | | | | | | | | | don't give an error and simply ingnore directive if we detect a loop of the #include_next. With this aproach coreutils-8.24.51-8802e compiles, but with errors: lib/libcoreutils.a: error: 'xnmalloc' defined twice lib/libcoreutils.a: error: 'xnrealloc' defined twice
* fix for the #include_next, v2seyko2015-10-171-1/+15
| | | | | | | | | A more correct fix. This one don't break old logic. But if include file is not found, we try to search again with the new compare rule. A description of the problem: http://permalink.gmane.org/gmane.comp.compilers.tinycc.devel/2769
* reverse a previous patchseyko2015-10-171-1/+3
| | | | a next version of the patch will follow
* fix for the #include_nextseyko2015-10-171-3/+1
| | | | skip include file only if include_file_name=current_file_name
* parsing "..." sequenceseyko2015-10-171-3/+1
| | | | | | | | | don't panic with error: '.' expected if there is only two '.' chars. Return tok='.' in such case. An asm code to test: jz do_move0 # .. then we have a normal low # .. or else we have a high
* tccpp.c: Avoid infinite loop on: printf '/**' | ./tcc -Edmund Grimley Evans2015-10-151-0/+2
|
* Revert all of my changes to directories & codingstyle.gus knight2015-07-291-0/+3430
|
* Reorganize the source tree.gus knight2015-07-271-3430/+0
| | | | | | | | | | * Documentation is now in "docs". * Source code is now in "src". * Misc. fixes here and there so that everything still works. I think I got everything in this commit, but I only tested this on Linux (Make) and Windows (CMake), so I might've messed something up on other platforms...
* Clean up lots of rogue tabs.gus knight2015-07-271-4/+4
| | | | | | Still some more tabs to be taken care of. arm-gen.c and tcccoff.c have so many style issues that I'm just going to throw clang-format at them.
* Trim trailing spaces everywhere.gus knight2015-07-271-36/+36
|
* redo of the -dD optionseyko2015-05-131-60/+100
| | | | | | | | functionality was broken some time ago and was removed by the "tccpp: fix issues, add tests" fix: LINE_MACRO_OUTPUT_FORMAT_NONE in pp_line() means: output '\n' and not "don't output at all"
* minor pp optimizationsseyko2015-05-121-3/+0
| | | | | | * remove free_defines() from tcc_preprocess() all cleanup will be done in tcc_delete * move a preprocessor file closing to tcc_delete too
* SYMBOL_NAME_LABEL(X) X##:seyko2015-05-121-1/+3
| | | | | | | | | | In the linux kernel sources: #ifdef __STDC__ #define SYMBOL_NAME_LABEL(X) X##: #else #define SYMBOL_NAME_LABEL(X) X/**/: #endif tcc is a STDC compiler and must handle 'X##:' case.
* tccpp: fix issues, add testsgrischka2015-05-091-711/+680
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fix some macro expansion issues * add some pp tests in tests/pp * improved tcc -E output for better diff'ability * remove -dD feature (quirky code, exotic feature, didn't work well) Based partially on ideas / researches from PipCet Some issues remain with VA_ARGS macros (if used in a rather tricky way). Also, to keep it simple, the pp doesn't automtically add any extra spaces to separate tokens which otherwise would form wrong tokens if re-read from tcc -E output (such as '+' '=') GCC does that, other compilers don't. * cleanups - #line 01 "file" / # 01 "file" processing - #pragma comment(lib,"foo") - tcc -E: forward some pragmas to output (pack, comment(lib)) - fix macro parameter list parsing mess from a3fc54345949535524d01319e1ca6378b7c2c201 a715d7143d9d17da17e67fec6af1c01409a71a31 (some coffee might help, next time ;) - introduce TOK_PPSTR - to have character constants as written in the file (similar to TOK_PPNUM) - allow '\' appear in macros - new functions begin/end_macro to: - fix switching macro levels during expansion - allow unget_tok to unget more than one tok - slight speedup by using bitflags in isidnum_table Also: - x86_64.c : fix decl after statements - i386-gen,c : fix a vstack leak with VLA on windows - configure/Makefile : build on windows (MSYS) was broken - tcc_warning: fflush stderr to keep output order (win32)
* Mostly revert "tccpp.c: minor fix I'd accidentally not committed"Philip2015-05-021-40/+17
| | | | | | | This reverts commit 27ec4f67a33a354c8f377dd4a5b42491c2b43beb. Sorry about that, I included changes which are still being tested, by accident.
* tccpp.c: minor fix I'd accidentally not committedPhilip2015-05-021-19/+43
| | | | Sorry about that. This should definitely fix Sergey's issue.
* minor fixPhilip2015-05-021-1/+2
| | | | | | | Fixes the issue reported by Sergey at http://lists.nongnu.org/archive/html/tinycc-devel/2015-05/msg00007.html I hope.
* tccpp.c: unterminated macro argument error messagePhilip2015-05-021-0/+2
| | | | | | | | #define a(x) x a(( would produce "error: , expected" when what's actually expected is a ')'.
* tccpp.c: fix GNU comma handlingPhilip2015-05-021-19/+34
| | | | | | | | | This requires moving TOK_PLCHLDR handling, but the new logic should make things easier even if (when?) GNU comma handling is removed. (Somewhat confusingly, GCC no longer supports GNU commas. See http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html for a description of past and current GCC behaviour.)
* tccpp.c: restore whitespace after failed macroPhilip2015-05-021-12/+35
| | | | | | | | | This fixes test7 described in: http://lists.nongnu.org/archive/html/tinycc-devel/2015-05/msg00002.html Note that the current code still adds excessive forced blank characters to its output, so this patch might not change visible behaviour.
* tccpp.c: correct # stringificationPhilip2015-05-021-4/+23
| | | | | | | | | | | | | | | | | | Fix handling of escape characters, spaces, and line feeds in macros or macro arguments that might yet be subject to # stringification. Should this be an -f option? I think memory usage increases only very slightly (in particular, while line feeds, stray \s, and spaces are preserved, comments are not), so it's probably not worth it to make it one. Note that macro_subst now checks for stray \s which are still left in the input stream after macro substitution, if desired. This patch depends on the previous patch, so if you revert that, please revert this patch, too. See http://lists.nongnu.org/archive/html/tinycc-devel/2015-05/msg00002.html
* tccpp.c: parse flag to accept stray \Philip2015-05-021-2/+8
| | | | | | | | | | | | | | | | | | | This adds a PARSE_FLAG_ACCEPT_STRAYS parse flag to accept stray backslashes in the source code, and uses it for pure preprocessing. For absolutely correct behaviour of # stringification, we need to use this flag when parsing macro definitions and in macro arguments, as well; this patch does not yet do so. The test case for that is something like #define STRINGIFY2(x) #x #define STRINGIFY(x) STRINGIFY2(x) STRINGIFY(\n) which should produce "\n", not a parse error or "\\n". See http://lists.nongnu.org/archive/html/tinycc-devel/2015-05/msg00002.html
* tccpp.c: fix endless loopPhilip2015-05-021-2/+3
| | | | | | | | | | Perhaps a better fix would be to ensure tok is set to TOK_EOF rather than 0 at the end of a macro stream. This partially fixes test2 of the examples given in: http://lists.nongnu.org/archive/html/tinycc-devel/2015-05/msg00002.html It's still failing, but at least it's not running out of memory now.