Commit Graph

144 Commits (meesbs)

Author SHA1 Message Date
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
Joe Soroka 0f0c2d9c02 weak redefinition of a symbol should weaken the original 2011-03-07 00:25:27 -08:00
Joe Soroka 38cbb40e90 __typeof(t) should not include storage modifiers of t 2011-03-06 22:32:35 -08:00
Joe Soroka 3beb383236 handle post-asm-label attributes on variables 2011-03-03 00:55:02 -08:00
Joe Soroka 823f832630 tcc: fix weak attribute handling 2011-03-02 13:31:09 -08:00
Jaroslav Kysela 85642f887c fix warning for tcctest.c introduced with my last commit 2011-02-22 13:55:21 +01:00
Jaroslav Kysela ab73c9bc4e fix another static struct init issue (arrays with unknown size at end) 2011-02-22 12:15:45 +01:00
Jaroslav Kysela dbefae52b0 Fix complex static initializers (handle additional '}' and '{' brackets)
- added an example to test suite
- the "warning: assignment discards qualifiers from pointer target type"
  is present but harmless
2011-02-22 12:15:44 +01:00
Thomas Preud'homme db560e9439 Revert "Implement C99 Variable Length Arrays"
This reverts commit a5a50eaafe.
2011-02-05 02:33:46 +01:00
Thomas Preud'homme 4b8470f3ae Revert "Disable C99 VLA when alloca is unavailable."
This reverts commit e3e5d4ad7a.
2011-02-05 02:33:45 +01:00
Thomas Preud'homme e3e5d4ad7a Disable C99 VLA when alloca is unavailable.
* Disable C99 VLA detection when alloca is unavailable and protect the
  new reference to TOK_alloca in decl_initializer in order to compile
  and run for architecture without working alloca.

  Not all code of C99 VLA is commented as it would required many ifdef
  stanza. Just the detection is commented so that VT_VLA is never set
  any type and the C99 VLA code is compiled but never called. However
  vpush_global_sym(&func_old_type, TOK_alloca) in decl_initializer needs
  to be protected by an ifdef stanza as well because it uses TOK_alloca.

* include alloca and C99 VLA tests according to availability of
  TOK_alloca instead of relying on the current architecture
2011-02-04 15:24:48 +01:00
Thomas Preud'homme a5a50eaafe Implement C99 Variable Length Arrays
Implement C99 Variable Length Arrays in tinycc:
- Support VLA with multiple level (nested vla)
- Update documentation with regards to VT_VLA
- Add a testsuite in tcctest.c
2011-02-04 02:22:25 +01:00
Joe Soroka b88677454b tcctest: plugged memleak (was polluting valgrind reports) 2011-02-01 16:05:57 -08:00
Joe Soroka 87d84b7cb8 tccasm: allow one-line prefix+op things like "rep stosb" 2011-02-01 15:37:58 -08:00
Joe Soroka 75c6695932 tccpp: fix bug in handling of recursive macros 2011-02-01 13:23:40 -08:00
Joe Soroka cf08675702 weak definitions overrule non-weak prototypes 2011-02-01 09:41:03 -08:00
Joe Soroka 4d5105c8f1 support weak attribute on variables 2011-02-01 00:37:53 -08:00
Shinichiro Hamaji 0ed7ba3f5e Support struct arguments with stdarg.h
- add __builtin_va_arg_types to check how arguments were passed
- move most code of stdarg into libtcc1.c
- remove __builtin_malloc and __builtin_free
- add a test case based on the bug report
  (http://www.mail-archive.com/tinycc-devel@nongnu.org/msg03036.html)
2010-12-28 19:32:40 +09:00
Shinichiro Hamaji 83f0a7b6f8 Test va_copy in tcctest.c 2010-12-28 17:53:56 +09:00
Shinichiro Hamaji c31dc7aa0c Fix casts from 32bit integer types to 64bit integer types.
This bug was reported in
http://lists.gnu.org/archive/html/tinycc-devel/2010-08/msg00050.html

In this case, we should not emit any code when we cast from VT_FUNC to VT_PTR.
2010-08-31 08:35:31 +09:00
Shinichiro Hamaji 1f6781f0ee Fix alignment around struct for SSE.
- Fix a wrong calculation for size of struct
- Handle cases where struct size isn't multple of 8
- Recover vstack after memcpy for pushing struct
- Add a float parameter for struct_assign_test1 to check SSE alignment
2010-08-27 02:32:19 +09:00
Shinichiro Hamaji 3a1380120d x86-64: change the type of size_t and ptrdiff_t.
size_t and ptrdiff_t should be unsigned long and long, respectively.
2009-08-24 13:30:03 +02:00
grischka 110a4edc15 drop alloca #define
(Because GNU's alloca.h unconditionally #undef's alloca)

Also, remove gcc specific sections in headers. and
instead change tests such that gcc does not use them.
2009-05-16 22:30:13 +02:00
grischka 5829791ffa fix makefiles etc for subdirs 2009-04-18 15:08:03 +02:00
grischka ea5e81bd6a new subdirs: include, lib, tests 2009-04-18 15:08:03 +02:00