this change fixes building of invalid types. The inner scope
struct P is return type of the forward decl foobar. The outer scope
foobar() call implicitely declares that function again, with int
return type; overall this leads to access within the sym free list,
effectively building up a type directly referring to itself, leading
to endless recursion later. The testcase is:
void n(void)
{
{
struct P {
int __val;
};
struct P foobar(); // 1
}
foobar(); // 2
}
I've not included it in tests2 for now, because tcc accepts this.
Ideally we would like to reject it (as 'int foobar();' is incompatible
with the earlier decl). clang also accepts it, but only because it's
not handling (1) above as an implicit decl of foobar (it warns, and
with -pedantic also warns about the type incompatiblity). GCC rejects
this.
Implementing that in tcc requires some surgery, as we need to differ
between these cases:
{ struct P foo(int); // 1
foo(); // no implicit decl, call to foo from 1
}
and
{ { struct P foo(int); // 2 }
foo(); // implicit decl, _incompatible_ with 2
}
normally the sym slot is meaningful only with VT_SYM. But we also
use it when mentioning a decl for inline asms with register vars,
conditional on being a VT_LOCAL entry. So when generating VT_LOCAL we
need to reset .sym as it might contain stale entries from the cmp_op
fields.
with fuzzed source code we might run into this with idx out of bounds.
We're going to error out on this later, but let's not access
out-of-bounds elements.
see testcase, reduced example of a situation reported by
Kyryl Melekhin in https://github.com/kyx0r/neatvi/ .
Problem is that setting up the VLA sp-save in a scope that isn't
entered at runtime leaves traces of it in outer scopes that then
try to restore the stack pointer from uninitialized slots.
If spaces are not escaped when generating the make dependencies file,
then if one of the dependencies has a space it would be interpreted as
two separate targets by Make, instead of just one.
Add myself to RELICENSING file
Use locking when writing tcov file
Fixed sometimes last line of function not shown
Merge tcc_tcov_add_file and tcc_add_tcov
Allow absolute file names
Count case labels with no code better
lib/tcov.c:
- can't be cross-compiled (needs stdio.h)
- can be included in libtcc1.a
Reason why bt-xxx.o/bcheck.o are linked separatly is because we
don't want then to linked into exe's and dlls at the same time.
tccgen.c: debug_modes
- don't waste debug function calls during normal execution.
libtcc.c:
- mem_debug: no C99 features in tcc please, for example
({compound expressions}): do not use.
tccgen.c: struct_layout:
- unaligned access is completely ok for most targets.
- Moreover the patch was triggering single byte mode even
for normal aligned access (as with tcc's SymAttr)
static Sym label: don't do this
arm-gen.c:
- use some #ifdefs to explain some code
tccpp.c:
- cleanup UCN chars
libtcc.c:
- replace openbsd library search
configure:
- cleanup strip fallouts
tccgen.c:
- expr_cond(): remove an exotic optimization that eventually
got fixed to do the contrary by a gv(RC_InT)
- pop_local_syms(): remove some args
- init_putv() : use write##le functions to avoid cross-compiler
unaligned access
- __bt_init(): remove unused param 'mode'
libtcc.c:
Fix unaligned load/store from magic3
tccgen.c:
For packed struct allways use single byte code
If field does not start at at align check it
Align stack correctly with vla
I have implemented the -ftest-coverage option. It works a bit different
from the gcc version. It output .tcov text file which looks almost the
same as a gcov file after a executable/so file is run.
Add lib/tcov.c file
Modify Makefiles to compile/install it
Add -ftest-coverage option in tcc.c/tcc.h/tcc-doc.texi
Add code to tccelf.c/tccgen.c/tccpe.c
Add gen_increment_tcov to tcc.h/*gen.c
unrelated changes:
Add sigemptyset in tccrun.c
Fix riscv64-gen.c tok_alloc label size
As the standard requires, take 4 hex digits after the \u opener of a
Universal Character Name, or take 8 hex digits after \U, but reject
smaller counts and don't consume more (https://port70.net/~nsz/c/c11/n1570.html#6.4.3,
https://port70.net/~nsz/c/c99/n1256.html#6.4.3).
The unicode codepoint used to get truncated to 1 byte. Now it gets expanded into UTF-8,
matching gcc & clang behavior on Linux.
TODO: Universal character names should also be supported in identifiers,
as in, e.g., char \u010dau_sv\u011bte[]="čau_světe";
Disable warning softfloat. OpenBSD works fine.
save/restore s0-s15 during memcpy call for structs
update configure script. Works now on raspberry pi/All BSD
Add eabi_mem.. functions in armeabi.c for OpenBSD
Fix fp register in tccrun.c for OpenBSD