Commit Graph

74 Commits (3d608d4b54edfdd9f394f06d2be0741387ac733a)

Author SHA1 Message Date
jiang 3d608d4b54 Delete a = (a > = 0)? A: -a; \ 2014-05-20 15:23:55 +08:00
jiang 0199123dd7 clean '\t' 2014-05-20 15:18:59 +08:00
jiang 196c999515 1 macro_push and macro_pop work I made a mistake, no matter the definition does not define can be macro_push.
And the modified tcctest.c test
2, pack: in the compiler under the mode of s1->ppfp, I have no clear ideas1->ppfp
Some advice thank you Roy to me.This patch, I hope I can pass the Roy test
2014-05-17 00:55:02 +08:00
jiang 276553c6b2 add push_macro test again 2014-05-16 15:44:51 +08:00
jiang 52891b6ff6 fix push_macro, asked Tom to help me testfix push_macro 2014-05-16 12:15:00 +08:00
jiang 07614b5e22 clean '\t' 2014-05-14 12:45:58 +08:00
jiang c6345b5a8a restore 2dd8587c2f32d17a2cd0443a60a614a3fa9bbe29 2014-05-13 22:05:38 +08:00
jiang 5e56fb635a Return to: e20c1eb99e
1: The new patch for the other machines still have the problem.
2: libcrt Rename (what if gcc had libcrt as well)
3: parse_number exact problem
4: VT_VLS is to allow tcc
     Compile the following
     int b = 9;
     struct st {
     int a;
     int b [b]
     };
     struct st st1;
     st1.b [8] = 9;
     printf ("% d \ n", st1.b [8]);

     tcc a problem. Due to problems in front, and now can not be improved
5: they commit much, bug difficult to lock, you can not let other people help develop.
6: ('\ t') too

Thanks to Michael and Ray
Their criticism I have benefited!
2014-05-04 13:18:31 +08:00
jiang 6c8207633f Fixes include the double quotes bug
Added push_macro, pop_macro support
Fix pack bug, when output with-E will pack the bug
2014-05-02 11:23:54 +08:00
jiang 5af0ea7fb8 Fix va_arg bug, Fix type conversion bug, an increase of loc_stack () function is used to manage loc 2014-04-30 15:26:45 +08:00
Vincent Lefevre 3e9a7e9d69 Corrected spelling mistakes in comments and strings 2014-04-07 13:31:00 +02:00
Michael Matz c4427747e6 arm: Provide alloca()
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.
2014-04-05 22:54:11 +02:00
Thomas Preud'homme 02d2ca8ac7 Fix and extend *FCAST test in tcctest.c
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.
2014-02-05 15:26:46 +08:00
Thomas Preud'homme 1415d7e6b6 Don't perform builtin_frame_address on ARM 2014-02-03 12:28:25 +08:00
Thomas Preud'homme c88c2706a2 Test long long to float conversions 2014-02-01 15:31:28 +08:00
Michael Matz f42a02efda tcctest: One more signed zero test
This also checks that -(-0.0) is +0.0.
2014-01-12 04:53:29 +01:00
Michael Matz 05c9b76131 Fix floating point unary minus and plus
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.
2014-01-12 04:44:27 +01:00
Thomas Preud'homme f2dbcf7594 Add ARM aeabi functions needed to run tcctest
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,
2013-12-11 10:15:30 +08:00
James Lyon 41d76e1fcb Fixed silly error in Windows build of tests (abitest-cc not linking to libtcc)
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.
2013-04-26 01:27:04 +01:00
James Lyon e31579b076 Fixed tests on Windows (including out-of-tree problems)
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.
2013-04-17 20:32:07 +01:00
grischka d5f4df09ff tests: cleanup
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)
2013-02-05 14:27:38 +01:00
Thomas Preud'homme f3e5649150 Don't do builtin_frame_address test with ARM gcc
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.
2013-01-26 20:31:14 +01:00
Thomas Preud'homme e92dbe4686 Stop returning 0 in cmp_comparison_test
cmp_comparison_test has no return value and should thus not return 0.
2013-01-06 12:26:53 +01:00
Kirill Smelkov b2a02961b4 Add support for __builtin_frame_address(level)
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>
2012-11-16 10:22:14 +04:00
Thomas Preud'homme 56e23984b9 Disable callsave_test for arm
Disable callsave_test for arm since it uses alloca which is unavailable
on this platform.
2012-07-30 22:52:34 +08:00
Michael Matz a42b029101 x86-64: Fix call saved register restore
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.
2012-06-10 09:01:26 +02:00
Michael Matz 2daae0dc99 x86_64: Fix compares with NaNs.
Comparisons with unordered doubles was broken, NaNs always
compare unequal (and unordered) to everything, including
to itself.
2012-05-13 02:21:51 +02:00
Michael Matz 9ca9c82ff8 Fix comparing comparisons
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.
2012-04-18 20:57:14 +02:00
Michael Matz 718fd591fa Make sizeof() be of type size_t
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).
2012-04-18 20:57:14 +02:00
Michael Matz 4c0d70ab07 Fix parsing function macro invocations
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.
2012-04-18 20:57:13 +02:00
Michael Matz 15f4ac2b1a Fix detection of labels with a typedef name
This needs to be accepted:
  typedef int foo;
  void f (void) { foo: return; }
namespaces for labels and types are different.  The problem is that
the block parser always tries to find a decl first and that routine
doesn't peek enough to detect this case.  Needs some adjustments
to unget_tok() so that we can call it even when we already called
it once, but next() didn't come around restoring the buffer yet.
(It lazily does so not when the buffer becomes empty, but rather
when the next call detects that the buffer is empty, i.e. it requires
two next() calls until the unget buffer gets switched back).
2012-04-18 20:57:13 +02:00
Michael Matz 1d0a5c2515 x86_64: Fix segfault for global data
When offsetted addresses of global non-static data are computed
multiple times in the same statement the x86_64 backend uses
gen_gotpcrel with offset, which implements an add insn on the
register given.  load() uses the R member of the to-be-loaded
value, which doesn't yet have a reg assigned in all cases.

So use the register we're supposed to load the value into as
that register.
2012-04-18 20:57:13 +02:00
Michael Matz 86ac6b9bee x86_64: Fix indirection in struct paramaters
The first loop setting up struct arguments must not remove
elements from the vstack (via vtop--), as gen_reg needs them to
potentially evict some argument still held in registers to stack.

Swapping the arg in question to top (and back to its place) also
simplifies the vstore call itself, as not funny save/restore
or some "non-existing" stack elements need to be done.

Generally for a stack a vop-- operation conceptually clobbers
that element, so further references to it aren't allowed anymore.
2012-04-18 20:57:13 +02:00
Michael Matz 5c0a2366a3 Fix bitfield loads into char/short.
Removes a premature optimization of char/short loads
rewriting the source type.  It did so also for bitfield
loads, thereby removing all the shifts/maskings.
2012-04-18 20:57:13 +02:00
Michael Matz 6471ec0a2b Fix conversion in a?0:ptr.
(cond ? 0 : ptr)->member wasn't handled correctly.  If one arm
is a null pointer constant (which also can be a pointer) the result
type is that of the other arm.
2012-04-18 20:57:13 +02:00
grischka 5e5e29f8fd tcctest: switch weak_toolate proto with impl
gcc -O0 didn't like this.
2011-08-06 16:11:57 +02:00
Joe Soroka 9b52e16a50 re-added negative-array-size testcase and fixed fix for it 2011-07-22 02:09:28 -07:00
grischka d7d8458888 Revert "better constant handling for expr_cond"
It produced wrong code with one of my test projects.
This reverts commit cd3d1a45f3.
2011-07-16 15:53:30 +02:00
Thomas Preud'homme 4ccb5662cb Fix array_test: move params to local vars
array_test is declared and called with no parameters but defined with
one parameter. Compilation succeed (definition is after the use so the
compiler consider the declaration) as well as link (the function exist
and has the right name) but running the test segfault on i386 platforms.

This patch moves the parameter to local variable. If the intention was
to call it with an array parameter then feel free to fix it again.
2011-07-12 15:10:59 +02:00
Joe Soroka c71798c376 handle arrays with a flexible member but no initializer 2011-07-11 00:18:36 -07:00
Joe Soroka cd3d1a45f3 better constant handling for expr_cond 2011-07-11 00:00:47 -07:00
Joe Soroka 38756b506f fix self-referential token pasting 2011-07-08 02:51:06 -07:00
Joe Soroka d01f65ef93 fix end-of-scope for self-referential macros 2011-07-08 00:55:34 -07:00
Joe Soroka cb2fa5eab9 VLA fix [1/3]: added testcase demonstrating VLA bug 2011-04-08 01:07:17 -07:00
Joe Soroka c94f80502e VLA bcheck works via bound alloca; add test, remove warning 2011-04-06 15:27:45 -07:00
Joe Soroka ace0f7f259 re-apply VLA by Thomas Preud'homme 2011-04-06 09:17:03 -07:00
Joe Soroka 4062d787da sizeof(struct with "flexible array member") is wrong 2011-03-18 17:45:43 -07:00
Joe Soroka 0b8aa909a3 fix c99 for-loop init decl scope (thanks: grischka)
see http://lists.nongnu.org/archive/html/tinycc-devel/2011-03/msg00005.html
2011-03-08 15:19:54 -08:00
Joe Soroka e23194a1fa support c99 for-loop init decls 2011-03-07 11:28:31 -08:00
Joe Soroka 4fbe3cda33 use new weaken_symbol() to fix another real-world corner case 2011-03-07 01:05:09 -08:00