aboutsummaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tccgen.c: Allow type attributes to prefix enum/struct/union nameVlad Vissoultchev2016-04-062-0/+14
| | | | | | From gcc docs: "You may also specify attributes between the enum, struct or union tag and the name of the type rather than after the closing brace." Adds `82_attribs_position.c` in `tests/tests2`
* utf8 in identifiersseyko2016-04-052-0/+11
| | | | | | | | | | | | | | 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; }
* nocode_wanted with while/for inside ({})seyko2016-04-052-0/+90
| | | | a test included.
* Identifiers can start and/or contain '.' in *.Sseyko2016-04-054-2/+26
| | | | | | | | | | | | | | | | | 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.
* Fix assignment to/from volatile typesMichael Matz2016-03-261-0/+11
| | | | | | | | | Code like this was broken: char volatile vi = i; See testcase, happens in ideosyncratic legacy code sprinkling volatile all over.
* Fix tokenization of TOK_DOTSMichael Matz2016-03-241-0/+5
| | | | | We really need to use PEEKC during tokenization so as to skip line continuations automatically.
* Fix type parsingMichael Matz2016-03-243-1/+10
| | | | | | the check on incomplete struct/union/enum types was too early, disallowing mixed specifiers and qualifiers. Simply rely on the size (->c) field for that. See testcases.
* Fix tests Makefiles on WindowsVlad Vissoultchev2016-03-143-2/+14
| | | | Compiled tcc.exe location is under $(top_srcdir)/win32
* tccgen.c: Fix flex array members some moreMichael Matz2016-03-112-0/+25
| | | | Last fix didn't work for function f1int in the added testcase.
* tccgen.c: In parse_btype, handle type qualifiers applied to arrays.Edmund Grimley Evans2016-01-111-0/+16
| | | | Also add some test cases in tests/tests2/39_typedef.c.
* tccgen.c: Try to make sizeof(!x) work.Edmund Grimley Evans2015-11-222-0/+3
| | | | tests/tests2/27_sizeof.*: Add test.
* tccgen.c: Bug fix for 992cbda and 3ff77a1: set nocode_wanted.Edmund Grimley Evans2015-11-212-0/+13
| | | | tests/tests2/78_vla_label.*: Add test.
* Improve constant propagation with "&&" and "||".Edmund Grimley Evans2015-11-201-1/+5
|
* tccgen.c: Recognise constant expressions with conditional operator.Edmund Grimley Evans2015-11-201-3/+14
| | | | tests/tests2/78_vla_label.c: Check that int a[1 ? 1 : 1] is not a VLA.
* tests/tests2/79_vla_continue.c: Fix off-by-one error.Edmund Grimley Evans2015-11-131-2/+2
|
* tests/tcctest.c: Fix up format strings.Edmund Grimley Evans2015-11-041-28/+28
|
* Enable variable-length arrays on arm64.Edmund Grimley Evans2015-10-311-2/+1
| | | | | arm64-gen.c: Implement gen_vla_sp_save, gen_vla_sp_restore, gen_vla_alloc. tests/Makefile: Run vla_test on arm64.
* Revert "fix-mixed-struct (patch by Pip Cet)"gus knight2015-07-291-4/+4
| | | | This reverts commit 4e04f67c94c97b4f28a4d73759a0ad38fb3a10f7. Requested by grischka.
* Revert all of my changes to directories & codingstyle.gus knight2015-07-295-82/+82
|
* Reorganize the source tree.gus knight2015-07-273-9/+9
| | | | | | | | | | * 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...
* Trim trailing spaces everywhere.gus knight2015-07-272-73/+73
|
* fix-mixed-struct (patch by Pip Cet)seyko2015-05-141-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Jsut for testing. It works for me (don't break anything) Small fixes for x86_64-gen.c in "tccpp: fix issues, add tests" are dropped in flavor of this patch. Pip Cet: Okay, here's a first patch that fixes the problem (but I've found another bug, yet unfixed, in the process), though it's not particularly pretty code (I tried hard to keep the changes to the minimum necessary). If we decide to actually get rid of VT_QLONG and VT_QFLOAT (please, can we?), there are some further simplifications in tccgen.c that might offset some of the cost of this patch. The idea is that an integer is no longer enough to describe how an argument is stored in registers. There are a number of possibilities (none, integer register, two integer registers, float register, two float registers, integer register plus float register, float register plus integer register), and instead of enumerating them I've introduced a RegArgs type that stores the offsets for each of our registers (for the other architectures, it's simply an int specifying the number of registers). If someone strongly prefers an enum, we could do that instead, but I believe this is a place where keeping things general is worth it, because this way it should be doable to add SSE or AVX support. There is one line in the patch that looks suspicious: } else { addr = (addr + align - 1) & -align; param_addr = addr; addr += size; - sse_param_index += reg_count; } break; However, this actually fixes one half of a bug we have when calling a function with eight double arguments "interrupted" by a two-double structure after the seventh double argument: f(double,double,double,double,double,double,double,struct { double x,y; },double); In this case, the last argument should be passed in %xmm7. This patch fixes the problem in gfunc_prolog, but not the corresponding problem in gfunc_call, which I'll try tackling next.
* tccpp: fix issues, add testsgrischka2015-05-0938-145/+266
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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)
* VLA fix: save stack pointer right after modificationPhilip2015-04-283-3/+28
| | | | | | | | | | | | | | | | This patch disables the optimization of saving stack pointers lazily, which didn't fully take into account that control flow might not reach the stack-saving instructions. I've decided to leave in the extra calls to vla_sp_save() in case anyone wants to restore this optimization. Tests added and enabled. There are two remaining bugs: VLA variables can be modified, and jumping into the scope of a declared VLA will cause a segfault rather than a compiler error. Both of these do not affect correct C code, but should be fixed at some point. Once VLA variables have been made properly immutable, we can share them with the saved stack pointer and save stack and instructions.
* fix VLA/continue issuePhilip2015-04-273-2/+99
| | | | | | | | | | | | | | | | | | as reported in http://lists.nongnu.org/archive/html/tinycc-devel/2015-04/msg00131.html. Note that this is one of two separate VLA bugs: A. labels aren't reached by program execution, so the stack pointer is never saved B. continue doesn't restore the stack pointer as goto does This fixes only B. I'm not sure whether the same issue applies to break as well as continue. Add a test case, but disable tests #78 and #79 for now as they're not fully fixed until the issue described in http://lists.nongnu.org/archive/html/tinycc-devel/2015-04/msg00110.html is resolved.
* add test case for VLA segfaultsPhilip2015-04-273-1/+25
| | | | | | | | | This test obviously shouldn't segfault, but currently does so. The problem is in the VLA code, which fails to save the stack pointer before taking a conditional branch in some cases. See this thread: http://lists.nongnu.org/archive/html/tinycc-devel/2015-04/msg00130.html
* fix another x86_64 ABI bugPhilip2015-04-261-0/+68
| | | | | | | | | | | The old code assumed that if an argument doesn't fit into the available registers, none of the subsequent arguments do, either. But that's wrong: passing 7 doubles, then a two-double struct, then another double should generate code that passes the 9th argument in the 8th register and the two-double struct on the stack. We now do so. However, this patch does not yet fix the function calling code to do the right thing in the same case.
* x86_64 ABI tests, which currently cause failuresPhilip2015-04-251-0/+86
| | | | | | | | | | | | | | With the x86_64 Linux ELF ABI, we're currently failing two of these three tests, which have been disabled for now. The problem is mixed structures such as struct { double x; char c; }, which the x86_64 ABI specifies are to be passed/returned in one integer register and one SSE register; our current approach, marking the structure as VT_QLONG or VT_QFLOAT, fails in this case. (It's possible to fix this by getting rid of VT_QLONG and VT_QFLOAT entirely as at https://github.com/pipcet/tinycc, but the changes aren't properly isolated at present. Anyway, there might be a less disruptive fix.)
* a test for the #pragma push/pop_macroseyko2015-04-253-1/+37
|
* Revert "* and #pragma pop_macro("macro_name")"grischka2015-04-233-30/+1
| | | | | | | | | | | | - pop_macro incorrect with initially undefined macro - horrible implementation (tcc_open_bf) - crashes eventually (abuse of Sym->prev_tok) - the (unrelated) asm_label part is the opposite of a fix (Despite of its name this variable has nothing to do with the built-in assembler) This reverts commit 0c8447db7970813292a8be74ee50e49091be5d15.
* fix a subtle x86-64 calling bugPhilip2015-04-231-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I ran into an issue playing with tinycc, and tracked it down to a rather weird assumption in the function calling code. This breaks only when varargs and float/double arguments are combined, I think, and only when calling GCC-generated (or non-TinyCC, at least) code. The problem is we sometimes generate code like this: 804a468: 4c 89 d9 mov %r11,%rcx 804a46b: b8 01 00 00 00 mov $0x1,%eax 804a470: 48 8b 45 c0 mov -0x40(%rbp),%rax 804a474: 4c 8b 18 mov (%rax),%r11 804a477: 41 ff d3 callq *%r11 for a function call. Note how $eax is first set to the correct value, then clobbered when we try to load the function pointer into R11. With the patch, the code generated is: 804a468: 4c 89 d9 mov %r11,%rcx 804a46b: b8 01 00 00 00 mov $0x1,%eax 804a470: 4c 8b 5d c0 mov -0x40(%rbp),%r11 804a474: 4d 8b 1b mov (%r11),%r11 804a477: 41 ff d3 callq *%r11 which is correct. This becomes an issue when get_reg(RC_INT) is modified not always to return %rax after a save_regs(0), because then another register (%ecx, say) is clobbered, and the function passed an invalid argument. A rather convoluted test case that generates the above code is included. Please note that the test will not cause a failure because TinyCC code ignores the %rax argument, but it will cause incorrect behavior when combined with GCC code, which might wrongly fail to save XMM registers and cause data corruption.
* * and #pragma pop_macro("macro_name")seyko2015-04-213-1/+30
| | | | | | | | | | * give warning if pragma is unknown for tcc * don't free asm_label in sym_free(), it's a job of the asm_free_labels(). The above pragmas are used in the mingw headers. Thise pragmas are implemented in gcc-4.5+ and current clang.
* add missing test from -fdollar-in-identifiers commitRamsay Jones2015-04-202-0/+55
| | | | | | | Commit 5ce2154c ("-fdollar-in-identifiers addon", 20-04-2015) forgot to include the test files from Daniel's patch. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* -fdollar-in-identifiers addonseyko2015-04-202-5/+9
| | | | | | | * disable a -fdollar-in-identifiers option in assembler files * a test is added This is a patch addon from Daniel Holden.
* a bounds checking code for the ARCH=x86_64seyko2015-04-101-5/+56
|
* fix installation amd bcheck for Windowsseyko2015-04-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | * define targetos=Windows when --enable-tcc32-mingw, --enable-cygwin, ... * use TARGETOS insteed HOST_OS when selecting PROGS * use "$(tccdir)" insteed $(tccdir) on install (spaces in path) * install tcc.exe too * produce bcheck.o when cross-compiling too (lib/Makefile) * force bcheck.o linking by compiling inside tcc_set_output_type() a dummy program with local array. Otherwise bcheck.o may be not linked. * replace %xz format specifier with %p in bcheck (don't supported on Windows) * call a __bound_init when __bound_ptr_add, __bound_ptr_indir, __bound_new_region, __bound_delete_region called. This is because a __bound_init inside ".init" section is not called on Windows for unknown reason. * print on stderr a message when an illegal pointer is returned: there is no segmentation violation on Windows for a program compiled with "tcc -b" * remove "C:" subdir on clean if $HOST_OS = "Linux" * default CFLAGS="-Wall -g -O0" insteed CFLAGS="-Wall -g -O2" to speed up compilation and more precise debugging.
* remove a compilation warnings for libtest and test3seyko2015-04-101-0/+2
| | | | | | | | | | ------------ libtest ------------ ./libtcc_test lib_path=.. <string>:11: warning: implicit declaration of function 'printf' <string>:13: warning: implicit declaration of function 'add' ------------ test3 ------------ tcctest.c:1982: warning: implicit declaration of function 'putchar' tcctest.c:2133: warning: implicit declaration of function 'strlen'
* A right fix for the array in struct initialization w/o '{'seyko2015-03-233-1/+107
| | | | | Parse a type if there is only one '(' before a type token. Otherwise a recursion will perform a job.
* skip 73_arm64,test on ARCH=x86-64: it fails on this ARCHseyko2015-03-201-0/+3
|
* Add some missing nocode_wanted guardThomas Preud'homme2015-03-103-0/+3
| | | | | | int i = i++ causes a segfault because of missing guard. Looking recursively at all backend functions called from middle end several more guard appeared to be missing.
* tests/Makefile: Quote to avoid: /bin/sh: 1: [: !=: unexpected operatorEdmund Grimley Evans2015-03-071-1/+1
|
* arm64: Optimise some integer operations with a constant operand.Edmund Grimley Evans2015-03-072-0/+119
|
* Disable floating-point test for ARM soft-floatseyko2015-03-042-2/+14
| | | | | | | | | | | From: Matteo Cypriani <mcy@lm7.fr> Date: Fri, 5 Sep 2014 23:22:56 -0400 Subject: Disable floating-point test for ARM soft-float tcc is not yet capable of doing softfloat floating-point operations on ARM, therefore we disable this test for these platforms. Note that tcc displays a warning to warn ARM users about this limitation (debian)
* disable-BTESTSseyko2015-03-041-1/+0
|
* Disable floating-point test for ARM soft-floatseyko2015-03-031-0/+2
| | | | | | | | | | | From: Matteo Cypriani <mcy@lm7.fr> Date: Fri, 5 Sep 2014 23:22:56 -0400 Subject: Disable floating-point test for ARM soft-float tcc is not yet capable of doing softfloat floating-point operations on ARM, therefore we disable this test for these platforms. Note that tcc displays a warning to warn ARM users about this limitation (debian)
* Turn on a implicit-function-declaration warning by default.seyko2015-03-032-0/+3
| | | | | | | | A non declared function leads to a seriuos problems. And while gcc don't turn this warning on lets tcc do it. This warning can be turned off by -Wno-implicit-function-declaration option. And autor must explicitly do this if program must be compiled with this warning off.
* arm64: Improve constant generation, with tests.Edmund Grimley Evans2015-03-022-0/+33
|
* 73_arm64.c: Avoid taking address of return value.Edmund Grimley Evans2015-02-261-21/+42
|
* Add 73_arm64 for testing some arm64 things, mostly PCS.Edmund Grimley Evans2015-02-253-0/+529
|
* tests/tcctest.c: Test COMPAT_TYPE(char *, signed char *).Edmund Grimley Evans2015-02-241-0/+2
|