Commit Graph

38 Commits (89ad24e7d63f7488c2796b30d41303f52663a8c4)

Author SHA1 Message Date
gus knight 89ad24e7d6 Revert all of my changes to directories & codingstyle. 2015-07-29 16:57:12 -04:00
gus knight 47e06c6d4e Reorganize the source tree.
* 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...
2015-07-27 16:03:25 -04:00
grischka 30df3189b1 tccpp: fix issues, add tests
* 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
    a3fc543459
    a715d7143d
    (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)
2015-05-09 14:29:39 +02:00
Philip 44c330d647 VLA fix: save stack pointer right after modification
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.
2015-04-28 09:23:29 +00:00
Philip d2dd6fdbfb fix VLA/continue issue
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.
2015-04-27 16:42:27 +00:00
Philip bd489a4815 add test case for VLA segfaults
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
2015-04-27 14:55:23 +00:00
seyko 9cbab3630e a test for the #pragma push/pop_macro 2015-04-25 15:03:50 +03:00
grischka 7c27186a83 Revert "* and #pragma pop_macro("macro_name")"
- 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 0c8447db79.
2015-04-23 23:26:46 +02:00
seyko 0c8447db79 * and #pragma pop_macro("macro_name")
* 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.
2015-04-21 06:34:35 +03:00
seyko 5ce2154c74 -fdollar-in-identifiers addon
* disable a -fdollar-in-identifiers option in assembler files
    * a test is added

    This is a patch addon from Daniel Holden.
2015-04-20 03:44:08 +03:00
seyko bd531ec1fd A right fix for the array in struct initialization w/o '{'
Parse a type if there is only one '(' before a type token.
Otherwise a recursion will perform a job.
2015-03-23 08:27:16 +03:00
seyko 63d068d3f2 skip 73_arm64,test on ARCH=x86-64: it fails on this ARCH 2015-03-20 16:01:06 +03:00
Thomas Preud'homme 5bcc3eed7b Add some missing nocode_wanted guard
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.
2015-03-10 23:27:14 +08:00
seyko d972472c53 Disable floating-point test for ARM soft-float
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)
2015-03-04 09:52:47 +03:00
Edmund Grimley Evans 8329facdfa Add 73_arm64 for testing some arm64 things, mostly PCS. 2015-02-25 22:51:41 +00:00
Thomas Preud'homme a6c3ce6ec0 The "open a whisky and cut your finger open" patch
Make integer constant parsing C99 compliant
2015-02-18 07:01:03 +00:00
Reimar Döffinger fb6331e0fa Fix macro expansion of empty args.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2015-01-18 22:00:10 +01:00
Lee Duhem 5a76c5d2f3 Fix parsing of binary floating point number
* tccpp.c (parse_number): `shift' should be 1 while parsing binary
floating point number.
* tests/tests2/70_floating_point_literals.c: New test cases for
floating point number parsing.
2014-12-15 16:32:08 +08:00
Matteo Cypriani 26b26f355f Filter-out warning about softfloat in tests2 2014-10-17 16:37:54 -04:00
Matteo Cypriani b84cdf6214 Clear CFLAGS & LDFLAGS in tests
Clear CFLAGS and LDFLAGS to build the tests, in case the main Makefile
passes some flags that aren't handled by tcc (we are not compiling tcc
here, we are using tcc to compile the tests).
2014-09-07 11:15:31 -04:00
jiang 89000c18dc Rename:
68_macro_concat.c -> 68_macro_param_list_err_1.c
69_macro_concat.c -> 69_macro_param_list_err_2.c
and Remove spaces
2014-07-01 23:54:49 +08:00
jiang a3fc543459 bug:
----------------------------------------------------------------------
#define hexCh(c (c >= 10 ? 'a' + c - 10 : '0' + c)
  hexCh(c);

out:
jiang@jiang:~/test$ ./tcc -E c4.c
# 1 "c4.c"

(c >= 10 ? 'a' + c - 10 : '0' + c);
---------------------------------------------------------------

#define hexCh(c/3) (c >= 10 ? 'a' + c - 10 : '0' + c)
hexCh(c);

out:
jiang@jiang:~/test$ ./tcc -E c4.c
# 1 "c4.c"

/3) (c >= 10 ? 'a' + c - 10 : '0' + c);
jiang@jiang:~/test$

after patch:

# 1 "c4.c"
c4.c:1: error: may not appear in macro parameter list: "("
jiang@jiang:~/test$

jiang@jiang:~/test$ ./tcc -E c4.c
# 1 "c4.c"
c4.c:1: error: may not appear in macro parameter list: "/"
jiang@jiang:~/test$
2014-06-29 20:35:57 +08:00
minux aa255f37f2 tests2: fix and enable 46_grep test. 2014-04-12 14:04:10 -04:00
minux 0a51386960 tests2: fix 30_hanoi test and enable it. 2014-04-12 13:37:37 -04:00
Thomas Preud'homme 6e56bb387d Fix preprocessor concat with empty arg 2014-04-12 16:11:42 +08:00
Thomas Preud'homme a715d7143d Prevent ## to appear at start or end of macro 2014-04-08 22:19:48 +08:00
Thomas Preud'homme 91d4db600b Add new tests for macro nesting 2014-04-07 23:30:57 +08:00
grischka f90bad0925 tests2: cleanup
- remove -norunsrc switch
  Meaning and usage (-run -norun...???) look sort of screwed.  Also
  general usefulness is unclear, so it was actually to support exactly
  one (not even very interesting) test

This partially reverts e31579b076
2014-04-07 11:20:45 +02:00
grischka 76accfb8d5 win32: libtcc1.a needs to be built with tcc
gcc/mingw produces msvc compatible pecoff objects, tcc only
knows ELF.
2014-04-07 11:16:06 +02:00
Michael Matz 3d18c9aa64 tests2: Build executables as well
The individual tests in tests2 are checked only with -run.  Build
(and check) executables as well, to test also building executables.
2014-04-05 17:35:00 +02:00
Thomas Preud'homme 3e56584223 Allow local redefinition of enumerator 2014-03-31 22:59:10 +08:00
Thomas Preud'homme 80811671d4 Add tests for previous fixes
Add tests for the fixes made in commits
76cb1144ef,
a465b7f58f,
0f522fb32a,
82969f045c and
673befd2d7.
2014-03-30 12:56:55 +08:00
Thomas Preud'homme f1f45a47ef Add test for previous commit
* Adapt tests2 Makefile to support testing tcc error reporting
* Add test for previous commit
2014-03-25 20:54:19 +08:00
grischka 2bd0daabbe misc. fixes
- tccgen: error out for cast to void, as in
      void foo(void) { return 1; }
  This avoids an assertion failure in x86_64-gen.c, also.
  also fix tests2/03_struct.c accordingly

- Error: "memory full" - be more specific

- Makefiles: remove circular dependencies, lookup tcctest.c from VPATH

- tcc.h: cleanup lib, include, crt and libgcc search paths"
  avoid duplication or trailing slashes with no CONFIG_MULTIARCHDIR
  (as from 9382d6f1a0)

- tcc.h: remove ";{B}" from PE search path
  in ce5e12c2f9 James Lyon wrote:
  "... I'm not sure this is the right way to fix this problem."
  And the answer is: No, please. (copying libtcc1.a for tests instead)

- win32/build_tcc.bat: do not move away a versioned file
2014-01-06 19:56:26 +01:00
James Lyon 1caee8ab3b Sorted out CMake on x86-64 and fixed silly XMM# bug introduced when working on Win64 stdargs.
I removed the XMM6/7 registers from the register list because they are not used
on Win64 however they are necessary for parameter passing on x86-64. I have now
restored them but not marked them with RC_FLOAT so they will not be used except
for parameter passing.
2013-04-25 22:30:53 +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
grischka 60cf64612c tests2: move into tests 2013-02-05 13:22:36 +01:00