aboutsummaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tccgen: nodata_wantedgrischka2017-07-165-49/+158
| | | | | | | | | | | | | | | | | | | | | | | | 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-144-12/+413
| | | | | | | | | | | | | | | | | | 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-142-0/+23
| | | | | 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-101-0/+30
| | | | | | | | | | | 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-101-0/+8
| | | | | | 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-102-0/+44
| | | | See testcase. Happens e.g. in the linux kernel.
* refactor bitfieldsgrischka2017-07-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* tccpp: allow "#define X defined Y ..."grischka2017-07-092-0/+44
| | | | | | | 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-092-0/+42
| | | | | | | | | | | 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: Fix corner caseMichael Matz2017-07-095-4/+135
| | | | | | | | | | | | | 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
|
* x86-64: Fix psABI stdarg prologueMichael Matz2017-05-271-0/+31
| | | | | | 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-271-2/+2
| | | | | This fixes two ABI testcases involving large arguments when there are still registers available for later args.
* configure: --config-musl/-uClibc switch & misc cleanupsgrischka2017-05-131-1/+1
| | | | | | | | | | | | | | | - 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
* bitfields: promote to signed intgrischka2017-05-092-0/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For integer promotion with for example arithmetics or expr_cond (x ? y : z), integral types need to be promoted to signed if they fit. According to latest standards, this also applies to bit-field types taking into account their specific width. In tcc, VT_BITFIELD set means width < original type width Field-widths between 33 and 63 are promoted to signed long long accordingly. struct { unsigned long long ullb:35; } s = { 1 }; #define X (s.ullb - 2) int main (void) { long long Y = X; printf("%d %016llx %016llx\n", X < 0, -X, -Y); return 0; } Results: GCC 4.7 : 0 0000000000000001 FFFFFFF800000001 MSVC : 1 0000000000000001 0000000000000001 TCC : 1 0000000000000001 0000000000000001 Also, gcc would promote long long bitfields of size < 32 to int as well. Example: struct { unsigned long long x:20; } t = { 123 }; /* with gcc: */ printf("%d %d\n", t.x, 456); /* with tcc: */ printf("%lld %d\n", t.x, 456);
* more minor fixesgrischka2017-05-072-12/+9
| | | | | | | | | | | | | | | | | | | | | | | | | * tccgen: re-allow long double constants for x87 cross sizeof (long double) may be 12 or 16 depending on host platform (i386/x86_64 on unix/windows). Except that it's 8 if the host is on windows and not gcc was used to compile tcc. * win64: fix builtin_va_start after VT_REF removal See also a8b83ce43a95fa519dacfe7690a3a0098af7909c * tcctest.c: remove outdated limitation for ll-bitfield test It always worked, there is no reason why it should not work in future. * libtcc1.c: exclude long double conversion on ARM * Makefile: remove CFLAGS from link recipes * lib/Makefile: use target DEFINES as passed from main Makefile * lib/armflush.c lib/va_list.c: factor out from libtcc1.c * arm-gen.c: disable "depreciated" warnings for now
* Accept extern initialized file-scope variablesMichael Matz2017-05-071-0/+2
| | | | | | 'extern int i = 42;' at file scope (but not in function scope!) is allowed and is a proper definition, even though questionable style; some compilers warn about this.
* struct-init: Fix zero initialization with multi-level designatorsMichael Matz2017-05-062-0/+37
| | | | | | | See the added testcase. When one used designators like .a.x to initialize sub-members of members, and didn't then initialize all of them the required zero-initialization of the other sub-members wasn't done. The fix also enables tiny code cleanups.
* Fix unsigned enum bit-fieldsMichael Matz2017-05-052-0/+57
| | | | | | See testcase. If an enum has only positive values, fits N bits, and is placed in a N-bit bit-field that bit-fields must be treated as unsigned, not signed.
* Fix segfault with invalid function defMichael Matz2017-05-051-0/+5
| | | | | | | This invalid function definition: int f()[] {} was tried to be handled but there was no testcase if it actually worked. This fixes it and adds a TCC only testcase.
* Tidy unary() a bitMichael Matz2017-05-021-2/+21
| | | | | | factor code a bit for transforming tokens into SValues. This revealed a bug in TOK_GET (see testcase), which happened to be harmless before. So fix that as well.
* Reorganize type parsingMichael Matz2017-05-021-0/+34
| | | | | Various corner cases for declarator parsing were incorrect. This reorganizes and fixes it, and somewhat simplifies it as well.
* Fix more bitfield corner casesMichael Matz2017-05-011-0/+6
| | | | | | | Our code generation assumes that it can load/store with the bit-fields base type, so bit_pos/bit_size must be in range for this. We could change the fields type or adjust offset/bit_pos; we do the latter.
* Remove a bit-field TODOMichael Matz2017-04-291-0/+7
| | | | | | Checked the lcc testsuite for bitfield stuff (in cq.c and fields.c), fixed one more error in initializing unnamed members (which have to be skipped), removed the TODO.
* Fix char bitfields corner caseMichael Matz2017-04-291-0/+6
| | | | See testcase.
* final adjustments for releasegrischka2017-04-252-35/+29
| | | | | | | | | | | | | | | | | | | | | - configure/Makefiles: minor adjustments - build-tcc.bat: add -static to gcc options (avoids libgcc_s*.dll dependency with some mingw versions) - tccpe.c/tcctools.c: eliminate MAX_PATH (not available for cross compilers) - tccasm.c: use uint64_t/strtoull in unary() (unsigned long sometimes is only uint32_t, as always on windows) - tccgen.c: Revert (f077d16c) "tccgen: gen_cast: cast FLOAT to DOUBLE" Was a rather experimental, tentative commit, not really necessary and somewhat ugly too. - cleanup recent osx support: - Makefile/libtcc.c: cleanup copy&paste code - tccpp.c: restore deleted function
* tccpp: Fix corner case of fnlike macro invocationMichael Matz2017-04-152-0/+18
| | | | | | | Arg substitution leaves placeholder marker in the stream for empty arguments. Those need to be skipped when searching for a fnlike macro invocation in the replacement list itself. See testcase.
* win: tests Makefile: fix global pathAvi Halachmi (:avih)2017-02-261-1/+1
| | | | | | | | | | Commit bb93064 changed the path seperator from ':' to ';', which was likely accidental. While path seperator on Windows is generally ';', the Makefile clearly expects a posix-y shell, and in such environments the separator is ':'. This fixes the test run in MSYS2 and MSYS(1) environments, which got broken on bb93064 .
* makefile: unify cross with native buildsgrischka2017-02-253-17/+19
| | | | | | | | | | | | | supports building cross compilers on the fly without need for configure --enable-cross $ make cross # all compilers $ make cross-TARGET # only TARGET-compiler & its libtcc1.a with TARGET one from i386 x86_64 i386-win32 x86_64-win32 arm arm64 arm-wince c67 Type 'make help' for more information
* x86-64-asm: Fix mov im64,rax encodingMichael Matz2017-02-231-0/+17
| | | | | | | the avoidance of mov im32->reg64 wasn't working when reg64 was rax. While fixing this also fix instructions which had the REX prefix hardcoded in opcode and so didn't support extended registers which would have added another REX prefix.
* tcc: re-enable correct option -r supportgrischka2017-02-202-4/+4
| | | | | | | | | | | | | | | Forgot about it. It allows to compile several sources (and other .o's) to one single .o file; tcc -r -o all.o f1.c f2.c f3.S o4.o ... Also: - option -fold-struct-init-code removed, no effect anymore - (tcc_)set_environment() moved to tcc.c - win32/lib/(win)crt1 minor fix & add dependency - debug line output for asm (tcc -c -g xxx.S) enabled - configure/Makefiles: x86-64 -> x86_64 changes - README: cleanup
* tcctools.c: integrate tiny_libmaker/_impdefgrischka2017-02-181-1/+1
| | | | | | | | | | | | | | usage: tcc -ar [rcsv] lib files... tcc -impdef lib.dll [-v] [-o lib.def] also: - support more files with -c: tcc -c f1.c f2.c ... - fix a bug which caused tcc f1.c f2.S to produce no asm - allow tcc -ar @listfile too - change prototype: _void_ tcc_set_options(...) - apply -Wl,-whole-archive when a librariy is given as libxxx.a also (not just for -lxxx)
* win32: adjust new unicode supportgrischka2017-02-181-6/+4
| | | | | | | | | | | | | | | | | | | - lib/Makefile: add (win)crt1_w.o - crt1.c/_runtmain: return to tcc & only use for UNICODE (because it might be not 100% reliable with for example wildcards (tcc *.c -run ...) - tccrun.c/tccpe.c: load -run startup_code only if called from tcc_run(). Otherwise main may not be defined. See libtcc_test.c - tests2/Makefile: pass extra options in FLAGS to allow overriding TCC Also: - tccpe.c: support weak attribute. (I first tried to solve the problem above by using it but then didn't)
* Temporary remove 76_dollards_in_identifiers when run on Windows as this test ↵Christian Jullien2017-02-181-0/+3
| | | | failes. To be checked why.
* Fix wrong name for 85 test.Christian Jullien2017-02-151-1/+1
|
* updates & cleanups (tcc-doc/Changelog/TODO ...)grischka2017-02-1314-62/+48
| | | | | | | | | | | | | | | - tcc-doc.texi: commandline option info update - Changelog/TODO: update - tests/tcctest.py: removed - tests/Makefile: weaktest fixed - tests/tests2: some files renamed and/or converted to unix LF - configure/Makefile: --enable-static option (no dll on win32) - win32/build-tcc.bat: msvc support - win32/tcc-win32.txt: build info update - win32/vs2015/: VS solution removed - win32/include/tcc/tcc_libm.h: #include statement fixed - tcc.c: -include <file> option help info - .gitignore: cleanup
* Fix testsuite invocationsMichael Matz2017-02-111-2/+2
| | | | | | The return code of $(FILTER) clobbers the return code of TCC itself. So just prepend messages to the generated output file and ignore return codes.
* update VERSION to 0.9.27grischka2017-02-082-5/+5
| | | | | | | | | Also: - in tests: generate .expect files only if not yet present, because 1) some files were adjusted manually 2) switching git branche might change timestamps and cause unwanted update
* tests: don't assume $(CC) is gccAvi Halachmi (:avih)2016-12-241-2/+2
| | | | This also allows self hosting + testing when $(CC) is tcc.
* tests: OOT build fixes etc.grischka2016-12-204-11/+26
| | | | | | | | | | | | | | | | | | | | | | tests/Makefile: fix out-of-tree build issues Also: - win64: align(16) MEM_DEBUG user memory on win64 the struct jmp_buf in the TCCState structure which we allocate by tcc_malloc needs alignment 16 because the msvcrt setjmp uses MMX instructions. - libtcc_test.c: win32/64 need __attribute__((dllimport)) for extern data objects - tcctest.c: exclude stuff that gcc does not compile except for relocation_test() the other issues are mostly ASM related. We should probably check GCC versions but I have no idea which mingw/gcc versions support what and which don't. - lib/Makefile: use tcc to compile libtcc1.a (except on arm which needs arm-asm
* Fix some code suppression falloutMichael Matz2016-12-206-1/+106
| | | | | | | | | | Some more subtle issues with code suppression: - outputting asms but not their operand setup is broken - but global asms must always be output - statement expressions are transparent to code suppression - vtop can't be transformed from VT_CMP/VT_JMP when nocode_wanted Also remove .exe files from tests2 if they don't fail.
* tests: add memory leak testgrischka2016-12-183-3/+16
| | | | | | | | | | | | | Also ... tcctest.c: - exclude stuff that gcc doesn't compile on windows. libtcc.c/tccpp.c: - use unsigned for memory sizes to avoid printf format warnings - use "file:line: message" to make IDE error parsers happy. tccgen.c: fix typo
* Fix gawk miscompileMichael Matz2016-12-182-2/+15
| | | | | See testcase. Function pointer use was hosed when the destination function wasn't also called normally by the program.
* i386: Fix various testsuite issuesMichael Matz2016-12-151-2/+22
| | | | | | | | | on 32bit long long support was sometimes broken. This fixes code-gen for long long values in switches, disables a x86-64 specific testcase and avoid an undefined shift amount. It comments out a bitfield test involving long long bitfields > 32 bit; with GCC layout they can straddle multiple words and code generation isn't prepared for this.
* struct-layout: Allow lowering of member alignmentMichael Matz2016-12-151-0/+16
| | | | | | when an alignment is explicitely given on the member itself, or on its types attributes then respect it always. Was only allowed to increase before, but GCC is allowing it.
* Support large alignment requestsMichael Matz2016-12-151-0/+7
| | | | | | | | The linux kernel has some structures that are page aligned, i.e. 4096. Instead of enlarging the bit fields to specify this, use the fact that alignment is always power of two, and store only the log2 minus 1 of it. The 5 bits are enough to specify an alignment of 1 << 30.
* Fix struct layout some moreMichael Matz2016-12-151-0/+86
| | | | | | Anonymous sub-sub-members weren't handled correctly. Bit-fields neither: this implements PCC layout for now. It temporarily disables MS-compatible bit-field layout.
* Split off record layoutingMichael Matz2016-12-151-4/+0
| | | | | | | | | | | Such struct decl: struct S { char a; int i;} __attribute__((packed)); should be accepted and cause S to be five bytes long (i.e. the packed attribute should matter). So we can't layout the members during parsing already. Split off the offset and alignment calculation for this.
* Fix 64bit enums and switch casesMichael Matz2016-12-151-0/+117
| | | | | | | See testcases. We now support 64bit case constants. At the same time also 64bit enum constants on L64 platforms (otherwise the Sym struct isn't large enough for now). The testcase also checks for various cases where sign/zero extension was confused.
* tccpp: Fix token pastingMichael Matz2016-12-152-0/+20
| | | | | | | | | See testcase. We must always paste tokens (at least if not currently substing a normal argument, which is a speed optimization only now) but at the same time must not regard a ## token coming from argument expansion as the token-paste operator, nor if we constructed a ## token due to pasting itself (that was already checked by pp/01.c).