aboutsummaryrefslogtreecommitdiff
path: root/tests/tcctest.c
Commit message (Collapse)AuthorAgeFilesLines
...
* inline-asm: Accept "flags" clobberMichael Matz2016-12-151-1/+1
|
* Support attribute between double pointer starsMichael Matz2016-12-151-0/+7
| | | | "int * __attribute__((something)) *" is supported by GCC.
* Fix function to pointer conversionMichael Matz2016-12-151-0/+7
| | | | | | | | This snippet is valid: void foo(void); ... foo + 42 ... the function designator is converted to pointer to function implicitely. gen_op didn't do that and bailed out.
* Fix parsing array typedefs of unknown sizeMichael Matz2016-12-151-0/+14
| | | | | | | | | | | This must compile: typedef int arrtype1[]; arrtype1 sinit19 = {1}; arrtype1 sinit20 = {2,3}; and generate two arrays of one resp. two elements. Before the fix the determined size of the first array was encoded in the type directly, so sinit20 couldn't be parsed anymore (because arrtype1 was thought to be only one element long).
* tccpp: Implement __BASE_FILE__ macroMichael Matz2016-12-151-0/+7
| | | | | Like __FILE__ but always refers to the command line file name also from inside headers.
* Implement __builtin_choose_exprMichael Matz2016-12-151-0/+13
| | | | Follows GCC implementation.
* Fix parsing attributes for struct declsMichael Matz2016-12-151-0/+33
| | | | | | | | | | | Given this code: struct __attribute__((...)) Name {...}; TCC was eating "Name", hence generating an anonymous struct. It also didn't apply any packed attributes to the parsed members. Both fixed. The testcase also contains a case that isn't yet handled by TCC (under a BROKEN #define).
* inline asm: accept concatenated strings in constraintsMichael Matz2016-12-151-1/+1
| | | | | This really should be handled implicitly in the preprocessor, but for now this is enough.
* Accept symbols in initializers also on 64 bitMichael Matz2016-12-151-0/+7
| | | | Those should use long or long long type, and generate a 64bit reloc.
* inline asm: Accept 'p' constraint and 'P' template modMichael Matz2016-12-151-0/+9
| | | | | 'p' is conservatively the same as 'r' and 'P' as template modifier can be ignored in TCC.
* Accept empty struct member declsMichael Matz2016-12-151-0/+5
| | | | | | | struct S { /*nothing*/; int a; }; is an acceptable struct declaration, there may be stray semicolons in the member list.
* x86-asm: Accept 'q' modifierMichael Matz2016-12-151-0/+11
| | | | In inline extended asm '%q1' refers to the 64bit register of operand 1.
* tests: add .so/.dll creation testgrischka2016-12-151-9/+0
| | | | | Also remove bitfield test from tcctest.c because gcc versions don't agree among each other.
* Implement gcc bitfield algorithm; add -mms-bitfieldsDavid Mertens2016-11-281-0/+9
|
* x86_64-asm: =m operand fixesgrischka2016-11-201-3/+25
| | | | | | | | | | | | | | | | | | | | | | The problem was with tcctest.c: unsigned set; __asm__("btsl %1,%0" : "=m"(set) : "Ir"(20) : "cc"); when with tcc compiled with the HAVE_SELINUX option, run with tcc -run, it would use large addresses far beyond the 32bits range when tcc did not use the pc-relative mode for accessing 'set' in global data memory. In fact the assembler did not know about %rip at all. Changes: - memory operands use (%rax) not (%eax) - conversion from VT_LLOCAL: use type VT_PTR - support 'k' modifier - support %rip register - support X(%rip) pc-relative addresses The test in tcctest.c is from Michael Matz.
* tccpp : "tcc -E -P" : suppress empty linesgrischka2016-10-091-0/+4
| | | | | | | | | Also: - regenerate all tests/pp/*.expect with gcc - test "insert one space" feature - test "0x1E-1" in asm mode case - PARSE_FLAG_SPACES: ignore \f\v\r better - tcc.h: move some things
* tccgen: arm/i386: save_reg_upstackgrischka2016-10-041-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tccgen.c:gv() when loading long long from lvalue, before was saving all registers which caused problems in the arm function call register parameter preparation, as with void foo(long long y, int x); int main(void) { unsigned int *xx[1], x; unsigned long long *yy[1], y; foo(**yy, **xx); return 0; } Now only the modified register is saved if necessary, as in this case where it is used to store the result of the post-inc: long long *p, v, **pp; v = 1; p = &v; p[0]++; printf("another long long spill test : %lld\n", *p); i386-gen.c : - found a similar problem with TOK_UMULL caused by the vstack juggle in tccgen:gen_opl() (bug seen only when using EBX as 4th register)
* switch: fix label sortingPavlas, Zdenek2016-10-031-0/+3
|
* Incorrect function call code on ARMv6Balazs Kezes2016-10-011-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On 2016-08-11 09:24 +0100, Balazs Kezes wrote: > I think it's just that that copy_params() never restores the spilled > registers. Maybe it needs some extra code at the end to see if any > parameters have been spilled to stack and then restore them? I've spent some time on this and I've found an alternative solution. Although I'm not entirely sure about it but I've attached a patch nevertheless. And while poking at that I've found another problem affecting the unsigned long long division on arm and I've attached a patch for that too. More details in the patches themselves. Please review and consider them for merging! Thank you! -- Balazs [PATCH 1/2] Fix slow unsigned long long division on ARM The macro AEABI_UXDIVMOD expands to this bit: #define AEABI_UXDIVMOD(name,type, rettype, typemacro) \ ... while (num >= den) { \ ... while ((q << 1) * den <= num && q * den <= typemacro ## _MAX / 2) \ q <<= 1; \ ... With the current ULONG_MAX version the inner loop goes only until 4 billion so the outer loop will progress very slowly if num is large. With ULLONG_MAX the inner loop works as expected. The current version is probably a result of a typo. The following bash snippet demonstrates the bug: $ uname -a Linux eper 4.4.16-2-ARCH #1 Wed Aug 10 20:03:13 MDT 2016 armv6l GNU/Linux $ cat div.c int printf(const char *, ...); int main(void) { unsigned long long num, denom; num = 12345678901234567ULL; denom = 7; printf("%lld\n", num / denom); return 0; } $ time tcc -run div.c 1763668414462081 real 0m16.291s user 0m15.860s sys 0m0.020s [PATCH 2/2] Fix long long dereference during argument passing on ARMv6 For some reason the code spills the register to the stack. copy_params in arm-gen.c doesn't expect this so bad code is generated. It's not entirely clear why the saving part is necessary. It was added in commit 59c35638 with the comment "fixed long long code gen bug" with no further clarification. Given that tcctest.c passes without this, maybe it's no longer needed? Let's remove it. Also add a new testcase just for this. After I've managed to make the tests compile on a raspberry pi, I get the following diff without this patch: --- test.ref 2016-08-22 22:12:43.380000000 +0100 +++ test.out3 2016-08-22 22:12:49.990000000 +0100 @@ -499,7 +499,7 @@ 2 1 0 1 0 4886718345 -shift: 9 9 9312 +shift: 291 291 291 shiftc: 36 36 2328 shiftc: 0 0 9998683865088 manyarg_test: More discussion on this thread: https://lists.nongnu.org/archive/html/tinycc-devel/2016-08/msg00004.html
* win64: fix va_arggrischka2016-07-101-0/+9
| | | | | | | | | | | fixes 5c35ba66c5ade4713bbd9c005e66889f6d7db293 Implementation was consistent within tcc but incompatible with the ABI (for example library functions vprintf etc) Also: - tccpp.c/get_tok_str() : avoid "unknown format "%llu" warning - x86_64_gen.c/gen_vla_alloc() : fix vstack leak
* x86-64: Run asmtest as wellMichael Matz2016-05-111-13/+27
| | | | | This fixes and activates the asm test that's part of tcctest.c also on x86-64, requiring a small fix for the 'm' constraint.
* tccgen: scopes levels for local symbols (update 1)grischka2016-05-051-0/+2
| | | | | | | Catch top level redeclarations too. Also fix mistakes in tcctest.c and the tcc sources (win32) showing up now.
* 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.
* tests/tcctest.c: Fix up format strings.Edmund Grimley Evans2015-11-041-28/+28
|
* Revert all of my changes to directories & codingstyle.gus knight2015-07-291-58/+58
|
* Trim trailing spaces everywhere.gus knight2015-07-271-58/+58
|
* tccpp: fix issues, add testsgrischka2015-05-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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)
* 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)
* tests/tcctest.c: Test COMPAT_TYPE(char *, signed char *).Edmund Grimley Evans2015-02-241-0/+2
|
* Corrected spelling mistakes in comments and stringsVincent Lefevre2014-04-071-1/+1
|
* arm: Provide alloca()Michael Matz2014-04-051-2/+2
| | | | | | This provides a simple implementation of alloca for ARM (and enables the associated testcase). As tcc for ARM doesn't contain an assembler, we'll have to resort using gcc for compiling it.
* Fix and extend *FCAST test in tcctest.cThomas Preud'homme2014-02-051-5/+8
| | | | | | | Result of float to unsigned integer conversion is undefined if float is negative. This commit take the absolute value of the float before doing the conversion to unsigned integer and add more float to integer conversion test.
* Don't perform builtin_frame_address on ARMThomas Preud'homme2014-02-031-2/+3
|
* Test long long to float conversionsThomas Preud'homme2014-02-011-0/+8
|
* tcctest: One more signed zero testMichael Matz2014-01-121-0/+6
| | | | This also checks that -(-0.0) is +0.0.
* Fix floating point unary minus and plusMichael Matz2014-01-121-0/+24
| | | | | | | negate(x) is subtract(-0,x), not subtract(+0,x), which makes a difference with signed zeros. Also +x was expressed as x+0, in order for the integer promotions to happen, but also mangles signed zeros, so just don't do that with floating types.
* Add ARM aeabi functions needed to run tcctestThomas Preud'homme2013-12-111-0/+67
| | | | | | | | | | | | Add implementation for float / integer conversion functions: __aeabi_d2lz, __aeabi_d2ulz, __aeabi_f2lz, __aeabi_f2ulz, __aeabi_l2d, __aeabi_l2f, __aeabi_ul2d, __aeabi_ul2f Add implementation for long long helper functions: __aeabi_ldivmod, __aeabi_uldivmod, __aeabi_llsl, __aeabi_llsr, __aeabi_lasr Add implementation for integer division functions: __aeabi_uidiv, __aeabi_uidivmod, __aeabi_idiv, __aeabi_idivmod,
* Fixed silly error in Windows build of tests (abitest-cc not linking to libtcc)James Lyon2013-04-261-30/+32
| | | | | | | | I really should do this when less tired; I keep breaking one platform while fixing another. I've also fixed some Windows issues with tcctest since Windows printf() uses different format flags to those on Linux, and removed some conditional compilation tests in tcctest since they now should work.
* Fixed tests on Windows (including out-of-tree problems)James Lyon2013-04-171-16/+31
| | | | | | | | | | | Modified tcctest.c so that it uses 'double' in place of 'long double' with MinGW since this is what TCC does, and what Visual C++ does. Added an option -norunsrc to tcc to allow argv[0] to be set independently of the compiled source when using tcc -run, which allows tests that rely on the value of argv[0] to work in out-of-tree builds. Also added Makefile rules to automatically update out-of-tree build Makefiles when in-tree Makefiles have changed.
* tests: cleanupgrischka2013-02-051-1/+4
| | | | | | | | | | | | | | | | tests: - add "hello" to test first basic compilation to file/memory - add "more" test (tests2 suite) - remove some tests tests2: - move into tests dir - Convert some files from DOS to unix LF - remove 2>&1 redirection win32: - tccrun.c: modify exception filter to exit correctly (needed for btest) - tcctest.c: exclude weak_test() (feature does not exist on win32)
* Don't do builtin_frame_address test with ARM gccThomas Preud'homme2013-01-261-0/+2
| | | | | | | | gcc fails the builtin_frame_address test on ARM so we disable it. As a consequence, the diff between gcc and tcc's output is unecessarily bigger. Given the big size of the diff currently, this doesn't make a big difference but may allow to detect a regression in tcc's implementation of builtin_frame_address.
* Stop returning 0 in cmp_comparison_testThomas Preud'homme2013-01-061-1/+0
| | | | cmp_comparison_test has no return value and should thus not return 0.
* Add support for __builtin_frame_address(level)Kirill Smelkov2012-11-161-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Continuing d6072d37 (Add __builtin_frame_address(0)) implement __builtin_frame_address for levels greater than zero, in order for tinycc to be able to compile its own lib/bcheck.c after cffb7af9 (lib/bcheck: Prevent __bound_local_new / __bound_local_delete from being miscompiled). I'm new to the internals, and used the most simple way to do it. Generated code is not very good for levels >= 2, compare gcc tcc level=0 mov %ebp,%eax lea 0x0(%ebp),%eax level=1 mov 0x0(%ebp),%eax mov 0x0(%ebp),%eax level=2 mov 0x0(%ebp),%eax mov 0x0(%ebp),%eax mov (%eax),%eax mov %eax,-0x10(%ebp) mov -0x10(%ebp),%eax mov (%eax),%eax level=3 mov 0x0(%ebp),%eax mov 0x0(%ebp),%eax mov (%eax),%eax mov (%eax),%ecx mov (%eax),%eax mov (%ecx),%eax But this is still an improvement and for bcheck we need level=1 for which the code is good. For the tests I had to force gcc use -O0 to not inline the functions. And -fno-omit-frame-pointer just in case. If someone knows how to improve the generated code - help is appreciated. Thanks, Kirill Cc: Michael Matz <matz@suse.de> Cc: Shinichiro Hamaji <shinichiro.hamaji@gmail.com>
* Disable callsave_test for armThomas Preud'homme2012-07-301-0/+2
| | | | | Disable callsave_test for arm since it uses alloca which is unavailable on this platform.
* x86-64: Fix call saved register restoreMichael Matz2012-06-101-0/+20
| | | | | | Loads of VT_LLOCAL values (which effectively represent saved addresses of lvalues) were done in VT_INT type, loosing the upper 32 bits. Needs to be done in VT_PTR type.
* x86_64: Fix compares with NaNs.Michael Matz2012-05-131-0/+66
| | | | | | Comparisons with unordered doubles was broken, NaNs always compare unequal (and unordered) to everything, including to itself.
* Fix comparing comparisonsMichael Matz2012-04-181-0/+30
| | | | | | | | | | | Sometimes the result of a comparison is not directly used in a jump, but in arithmetic or further comparisons. If those further things do a vswap() with the VT_CMP as current top, and then generate instructions for the new top, this most probably destroys the flags (e.g. if it's a bitfield load like in the example). vswap() must do the same like vsetc() and not allow VT_CMP vtops to be moved down.
* Make sizeof() be of type size_tMichael Matz2012-04-181-0/+16
| | | | | | | | This matters when sizeof is directly used in arithmetic, ala "uintptr_t t; t &= -sizeof(long)" (for alignment). When sizeof isn't size_t (as it's specified to be) this masking will truncate the high bits of the uintptr_t object (if uintptr_t is larger than uint).
* Fix parsing function macro invocationsMichael Matz2012-04-181-0/+4
| | | | | | If a function macro name is separated from the parentheses in an macro invocation the substitution doesn't take place. Fix this by handling comments.