aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Use more conventional punctuation for sequential assignmentsLarry Doolittle2017-09-251-6/+6
|
* freebsd: allow building tcc which targets windowsAvi Halachmi (:avih)2017-09-251-1/+2
| | | | | | | | | | | Currently tcc doesn't have a compile-time config indicating that the target is freebsd, and as a result, the tcc binary adds freebsh stuff to elf headers if the compile-time (of tcc) *host* is freebsd. Test also that the target is not PE while generating an elf header. This still likely fails (but untested) when tcc targets other non-freebsd systems on a freebsd system, but for now fix it only when targetting windows.
* Fix some spelling in documentationLarry Doolittle2017-09-241-5/+5
|
* Spelling fixesLarry Doolittle2017-09-2419-28/+28
| | | | Comments only, no change to functionality
* Convert two .c files to LF line endingsLarry Doolittle2017-09-242-317/+317
| | | | ... matching the other 157 .c files in the tree
* 'long' reviewgrischka2017-09-246-176/+164
| | | | | | | | | | | | | | | | | | | | | add some features for more complete 'long' support tcc.h: - use LONG_SIZE=4/8 instead of TCC_LONG_ARE_64_BIT tccgen.c: - add ptrdiff_type, update size_type - support shift and ?: operations - support long enum types - display 'long' from type_to_str - nwchar_t is unsigned short on windows - unrelated: use memcpy in init_putv for long doubles to avoid random bytes in the image (if tcc was compiled by gcc) for diff purposes. tccpp.c: - make parse_number return correct types - improve multi-character-constants 'XX' 'abcd' Changelog: - update
* gen_addrpc32: absolute ptr needs *ABS* relocationZdenek Pavlas2017-09-111-2/+1
| | | | | | | Dereferencing of absolute pointers is broken on x86_64, eg: *(int*)NULL does not segfault but returns -4 instead *(char*)(-10L << 20) does not return 0x55 (vsyscall page, push rbp)
* Add test case for fastcall calling conventionZhang Boyang2017-09-103-1/+278
|
* Add test case for AL/AX extending problemZhang Boyang2017-09-103-0/+53
|
* Add test case for wide char handling in wide string literalZhang Boyang2017-09-102-0/+13
|
* Fix calling function pointers casted from intergers in DLLZhang Boyang2017-09-091-11/+3
| | | | | | The code generated for "((void (*)(void))0x12345678)()" will be a single "CALL 0x12345678" in previous code. However, this will not work for DLLs, because "CALL imm" is PC related, DLL relocation will break the code. This commit fixed the problem by forcing TCC generates indirect CALLs in this situation.
* Fix AL/AX is not extended to EAX when calling indirectlyZhang Boyang2017-09-091-6/+8
| | | | | AL/AX should be extended to EAX when calling functions. However, the previous code did this only for direct calls, indirect calls were ignored. New code also avoid redundant code when generating JMP instruction. (i.e. expanding code should be generated with CALL instruction only)
* Fix wide char handling in wide string literalZhang Boyang2017-09-091-1/+67
| | | | | | This commit fixed the problem that TCC directly cast each byte in wide string literal to wchar_t, which is wrong when wide string literal contains real wide chars. It fixed the problem by assuming input charset is UTF-8, and wchar_t stores wide chars in UTF-16 (Windows) or UTF-32 (others). The UTF-8 decoder is coded according to The Unicode Standard Version 10.
* 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)".