aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* called function should pop the arguments when using fastcallZhang Boyang2017-08-211-3/+3
|
* Convert from ISO-8859-1 to UTF-8. See aa812e8.Edmund Grimley Evans2017-07-261-1/+1
|
* Revert "use int for ssize_t, (u)intptr_t instead of long in stddef.h"Matthias Gatto2017-07-262-10/+3
| | | | | | This reverts commit 52622c3c0365ad497ce1188e433ac5f0a721c283. Because 28b7c9 was right.
* Revert "simplify VT_LONG parsing"matthias2017-07-251-3/+3
| | | | | | | | | Too simple long parsion. Take me a long long long time to see my mistake, Sorry (long long long wasn't see as an error) This reverts commit a4cd2805f95e1369254762478883e91050f2cba1.
* Remove debug echo in Cygwin MakefileChristian Jullien2017-07-251-1/+1
|
* Update Cygwin Makefile to use -B. for bootstrapChristian Jullien2017-07-251-26/+26
|
* use int for ssize_t, (u)intptr_t instead of long in stddef.hMatthias Gatto2017-07-252-3/+10
|
* check that _Generic match 'signed long int' as 'long'Matthias Gatto2017-07-252-0/+4
|
* simplify VT_LONG parsingMatthias Gatto2017-07-251-3/+3
|
* Update Cygwin Makefile to work with recent changes about ONE_SOURCE and ↵Christian Jullien2017-07-251-5/+7
| | | | CONFG_TCCDIR
* define __SIZE_TYPE__ and __PTRDIFF_TYPE__ as unsigned int and int.Matthias Gatto2017-07-251-2/+2
| | | | | | | As long is now a qualifier, and because compare_type will notice that variables are not the same type, we can't use long as int anymore. So, I've redefine __SIZE_TYPE__ as unsigned int and __PTRDIFF_TYPE__ as int.
* remove inside_generic hackMatthias Gatto2017-07-242-7/+8
| | | | | define uint64_t and int64_t as 'long' instead of 'long long' when __LP64__ is define.
* tccgen: nodata_wanted fix, default ONE_SOURCE, etc...grischka2017-07-2325-163/+350
| | | | | | | | | | | | | | | | | | | | | | | | | tccgen.c: doubles need to be aligned, on ARM. The section_reserve() in init_putv does not do that. -D ONE_SOURCE: is now the default and not longer needed. Also, tcc.h now sets the default native target. These both make compiling tcc simple as "gcc tcc.c -o tcc -ldl" again. arm-asm.c: enable pseudo asm also for inline asm tests/tests2/Makefile: disable bitfield tests except on windows and x86_64 and don't generate-always tcc.c: fix a loop with -dt on errors configure: print compiler version (as recognized) tccpp.c: actually define symbols for tcc -dt clear static variables (needed for -dt or libtcc usage) 96_nodata_wanted.c: use __label__ instead of asm lib/files: use native symbols (__i386__ etc.) instead of TCC_TARGET_...
* mutiples fix for _Genericmatthias2017-07-215-23/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * check that _Generic don't match unsigned char * with char * this case is usefull as with -funsigned-char, 'char *' are unsigned * change VT_LONG so it's now a qualifier VT_LONG are never use for code generation, but only durring parsing state, in _Generic we need to be able to make diference between 'long' and 'long long' So VT_LONG is now use as a type qualifier, it's old behaviour is still here, but we can keep trace of what was a long and what wasn't * add TOK_CLONG and TOK_CULONG tcc was directly converting value like '7171L' into TOK_CLLONG or TOK_CINT depending of the machine architecture. because of that, we was unable to make diference between a long and a long long, which doesn't work with _Generic. So now 7171L is a TOK_CLONG, and we can handle _Generic properly * check that _Generic can make diference between long and long long * uncomment "type match twice" as it should now pass tests on any platforms * add inside_generic global the point of this variable is to use VT_LONG in comparaison only when we are evaluating a _Generic. problem is with my lastest patchs tcc can now make the diference between a 'long long' and a 'long', but in 64 bit stddef.h typedef uint64_t as typedef signed long long int int64_t and stdint.h as unsigned long int, so tcc break when stdint.h and stddef.h are include together. Another solution woud be to modifie include/stddef.h so it define uint64_t as unsigned long int when processor is 64 bit, but this could break some legacy code, so for now, VT_LONG are use only inside generc. * check that _Generic parse first argument correctly * check that _Generic evaluate correctly exresion like "f() / 2"
* tcc -dt -run ... : simpler is bettergrischka2017-07-2031-446/+323
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * -dt now with lowercase t * test snippets now separated by real preprocessor statements which is valid C also for other compilers #if defined test_xxx < test snippet x > #elif defined test_yyy < test snippet y > #elif ... #endif * simpler implementation, behaves like -run if no 'test_...' macros are seen, works with -E too * for demonstration I combined some of the small tests for errors and warnings (56..63,74) in "60_errors_and_warnings.c" Also: * libtcc.c: put tcc_preprocess() and tcc_assemble() under the setjmp clause to let them return to caller after errors. This is for -dt -E. * tccgen.c: - get rid of save/restore_parse_state(), macro_ptr is saved by begin_macro anyway, now line_num too. - use expr_eq for parsing _Generic's controlling_type - set nocode_wanted with const_wanted. too, This is to keep VT_JMP on vtop when parsing preprocessor expressions. * tccpp.c: tcc -E: suppress trailing whitespace from lines with comments (that -E removes) such as NO_GOTPLT_ENTRY,\t /* never generate ... */
* fix typo sellector -> selectorMatthias Gatto2017-07-181-1/+1
|
* fix typo: march -> matchmatthias2017-07-181-1/+1
|
* unqualify volatile in _Generic type checkingMatthias Gatto2017-07-181-0/+1
|
* Fix cross compilersMichael Matz2017-07-162-0/+4
| | | | Only native compilers support -run and hence the new -dT.
* tccgen: nodata_wantedgrischka2017-07-1610-85/+329
| | | | | | | | | | | | | | | | | | | | | | | | The existing variable 'nocode_wanted' is now used to control output of static data too. So... (nocode_wanted == 0) code and data (normal within functions) (nocode_wanted < 0) means: no code, but data (global or static data) (nocode_wanted > 0) means: no code and no data (code and data suppressed) (nocode_wanted & 0xC0000000) means: we're in declaration of static data Also: new option '-dT' to be used with -run tcc -dT -run file.c This will look in file.c for certain comment-boundaries: /*-* test-xxx: ...some description */ and then for each test below run it from memory. This way various features and error messages can be tested with one single file. See 96_nodata_wanted.c for an example. Also: tccgen.c: one more bitfield fix
* #pragma comment(option,"-..."), bitfields test, etc...grischka2017-07-1410-54/+475
| | | | | | | | | | | | | | | | | | tccpp.c: * #pragma comment(option,"-some-option") to set commandline option from C code. May work only for some options. libtcc.c: * option "-d1..9": sets a 'g_debug' global variable. (for development) tests2/Makefile: * new make targets: tests2.37 / tests2.37+ run single test from tests2, optionally update .expect * new variable GEN-ALWAYS to always generate certain .expects * bitfields test tccgen.c: * bitfields: fix a bug and improve slightly more * _Generic: ignore "type match twice"
* Fix function typesMichael Matz2017-07-143-11/+42
| | | | | various cases of function type uses were broken by recent attribute refactoring, this fixes and adds testcases for them.
* tccasm: Fix local statics referenced from asmsMichael Matz2017-07-102-0/+36
| | | | | | | | | | | The assembler uses the ->sym_scope member to walk up the symbols until finding a non-automatic symbol. Since reordering the members of Sym the sym_scope member contains a scope even for local statics. Formerly the use of asm_label for statics was implicitely clearing sym_scope, now we have to do that explicitely. Add a testcase for that, and one I encountered when moving the clearing of sym_scope too deep into the call chain (into put_extern_sym).
* Fix statement exprs returning a local labelMichael Matz2017-07-104-6/+16
| | | | | | Like returned local variables also labels local to a statement expression can be returned, and so their symbols must not be immediately freed (though they need to be removed from the symbol table).
* enums: Accept GNU extensionMichael Matz2017-07-103-2/+46
| | | | See testcase. Happens e.g. in the linux kernel.
* refactor bitfieldsgrischka2017-07-093-193/+384
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use 2 level strategy to access packed bitfields cleanly: 1) Allow to override the original declaration type with an auxilary "access type". This solves cases such as struct { ... unsigned f1:1; }; by using VT_BYTE to access f1. 2) Allow byte-wise split accesses using two new functions load/store_packed_bf. This solves any cases, also ones such as struct __attribute((packed)) _s { unsigned x : 12; unsigned char y : 7; unsigned z : 28; unsigned a: 3; unsigned b: 3; unsigned c: 3; }; where for field 'z': - VT_INT access from offset 2 would be unaligned - VT_LLONG from offset 0 would go past the total struct size (7) and for field 'a' because it is in two bytes and aligned access with VT_SHORT/INT is not possible. Also, static bitfield initializers are stored byte-wise always. Also, cleanup the struct_layout function a bit.
* refactor enumsgrischka2017-07-094-102/+107
| | | | | | Eliminate VT_ENUM as a basic type. Instead use the integral types VT_InT/VT_LLONG with an additional flag to indicate that it is an enum.
* refactor sym & attributesgrischka2017-07-099-291/+286
| | | | | | | | | | | | tcc.h: * cleanup struct 'Sym' * include some 'Attributes' into 'Sym' * in turn get rid of VT_IM/EXPORT, VT_WEAK * re-number VT_XXX flags * replace some 'long' function args by 'int' tccgen.c: * refactor parse_btype()
* unsorted adjustmentsgrischka2017-07-0911-80/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - configure * use aarch64 instead of arm64 - Makefile * rename the custom include file to "config-extra.mak" * Also avoid "rm -r /*" if $(tccdir) is empty - pp/Makefile * fix .expect generation with gcc - tcc.h * cleanup #defines for _MSC_VER - tccgen.c: * fix const-propagation for &,| * fix anonymous named struct (ms-extension) and enable -fms-extension by default - i386-gen.c * clear VT_DEFSIGN - x86_64-gen.c/win64: * fix passing structs in registers * fix alloca (need to keep "func_scratch" below each alloca area on stack) (This allows to compile a working gnu-make on win64) - tccpp.c * alternative approach to 37999a4fbf3487b363fd0c2f9b7ab622401b202a This is to avoid some slowdown with ## token pasting. * get_tok_str() : return <eof> for TOK_EOF * -funsigned-char: apply to "string" literals as well - tccpe/tools.c: -impdef: support both 32 and 64 bit dlls anyway
* tccpp: allow "#define X defined Y ..."grischka2017-07-094-26/+69
| | | | | | | That means: we do not macro-expand the argument of 'defined' Also: store the last token position into the TokenString structure in order to get rid of the tok_last function.
* tccpp: Implement __COUNTER__Michael Matz2017-07-095-11/+72
| | | | | | | | | | | This requires one more change in how macro arguments are expanded: the standard requires that macro args are expanded before substituting into the replacement list. This implies expanding them only once even when they occur multiple times in the list. TCC expanded them repeatedly in that case. Without __COUNTER__ that's harmless. So, simply always expand arguments (when used without # and ##) once and store the resulting tokens.
* tccpp: CleanupMichael Matz2017-07-091-126/+111
| | | | | With last change the can_read_stream flag is unneeded, so tidy this a bit.
* tccpp: Fix corner caseMichael Matz2017-07-096-10/+143
| | | | | | | | | | | | | See added testcase 19.c from a bug report. The problem is reading outside the arguments buffers, even though we aren't allowed to. The single can_read_stream variable is not enough, sometimes we need to be able to pop into outer contexts but not into arbitrarily outside contexts. The trick is to terminate argument tokens with a EOF (and not just with 0 that makes us pop contexts), and deal with that in the few places we have to, This enables some cleanups of the can_read_stream variable use.
* add _Generic testMatthias Gatto2017-07-052-0/+60
|
* add C11's _GenericMatthias Gatto2017-07-052-1/+74
| | | | | | | | | | Simple implementation, I'm not even sure to respect C standart here, but it should work with most use case. This add an case in unary(), and generate TokString depending of _Generic controlling exression, use begin_macro to "push" the generated TokString, then call unary() again before exiting the switch so the just add token are reevaluate again.
* Revert "String literals are always const"Michael Matz2017-07-041-3/+3
| | | | | | | | | | | This reverts commit d4fe9aba3fc6f4b9cc97b100e86ffe7af5c29619. I was confused by the fact that string literals aren't writable. Nevertheless the type isn't const. As extension in GCC it's const with -Wwrite-string, which is exactly what we had before. GCC also wonders in a comment if it's really a good idea to change expression types based on warning flags (IMHO it's not), but let's be compatible. So restore the state from before.
* Extend skip_or_save_blockMichael Matz2017-07-031-1/+1
| | | | | Make it stop also before outer level closing parens. This way we can now also skip/save the expression inside "foobar(42 + 41)".
* Improve skip_or_save_blockMichael Matz2017-07-031-7/+7
| | | | | Stop at level 0 only for matching outer '}' (which is added). Otherwise stop only at stop tokens (which aren't added).
* String literals are always constMichael Matz2017-07-031-3/+3
| | | | | | Don't make the standard mandated types of string literals depends on warning options. Instead make them always const, but limit the emission of the warning by that option.
* Align 'implicit-function-declaration' option comment with other comments ↵Christian Jullien2017-06-101-1/+1
| | | | (cosmetic change)
* Add -O2 when compiling tcc on Windows. Not sure this flag is really used by tcc.Christian Jullien2017-06-101-24/+24
|
* When creating a staticaly linked ELF program should not includeEmil2017-06-091-5/+7
| | | | | | | | | any dyn symbols. The if( !s1->static_link ) prevents tcc from crashing when buiding a program linked to dietlibc. The section header should not contain the number of local symbols when the sh_size is null. This makes the header compliant and IDA will not issue any warnings when an executable is disassembled.
* force i386-win32-tcc.exe to be a 32bit binary. Run tests in both 32/64 bits ↵U-NELSON\jullien2017-06-051-1/+5
| | | | on Windows.
* Add more common tests to be run from win32/MakefileU-NELSON\jullien2017-06-041-2/+2
|
* Windows test Makefile target also test pp tests.Christian Jullien2017-05-281-0/+1
|
* Limit access end-of-struct warning a bitMichael Matz2017-05-271-1/+1
| | | | | | | Only warn if the struct has a non-zero size. You can't create objects of zero-sized structs, but they can be used inside sizeof (e.g. "sizeof (struct {int :0;})". The warning would always trigger for these, but as no objects can be created no accesses can ever happen.
* x86-64: Fix psABI stdarg prologueMichael Matz2017-05-272-12/+37
| | | | | | If there were more than 6 integer arguments before the ellipsis, or there were used more than 8 slots used until the ellipsis (e.g. by a large intermediate struct) we generated wrong code. See testcase.
* x86-64: Rewrite linux parameter passingMichael Matz2017-05-272-176/+86
| | | | | This fixes two ABI testcases involving large arguments when there are still registers available for later args.
* the R_X86_64_GOTOFF64 relocation was missingAron BARATH2017-05-161-0/+5
|
* configure: --config-musl/-uClibc switch & misc cleanupsgrischka2017-05-1318-240/+181
| | | | | | | | | | | | | | | - configure: - add --config-uClibc,-musl switch and suggest to use it if uClibc/musl is detected - make warning options magic clang compatible - simplify (use $confvars instead of individual options) - Revert "Remove some unused-parameter lint" 7443db0d5f841b81a55e918bf8c228dd20f9ddb2 rather use -Wno-unused-parameter (or just not -Wextra) - #ifdef functions that are unused on some targets - tccgen.c: use PTR_SIZE==8 instead of (X86_64 || ARM64) - tccpe.c: fix some warnings - integrate dummy arm-asm better