aboutsummaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* opt: Start optimizing dead code a bitMichael Matz2016-12-153-0/+167
| | | | | | | If a condition is always zero/non-zero we can omit the then or else code. This is complicated a bit by having to deal with labels that might make such code reachable without us yet knowing during parsing.
* Fix more nocode_wanted jump problemsMichael Matz2016-12-152-0/+36
| | | | | | | In statement expression we really mustn't emit backward jumps under nocode_wanted (they will form infinte loops as no expressions are evaluated). Do-while and explicit loop with gotos weren't handled.
* Fix aliases on 64 bitMichael Matz2016-12-151-0/+1
| | | | Use correct width ELF structure.
* Fix sizeof(char[a])Michael Matz2016-12-151-0/+10
| | | | | The sizes of VLAs need to be evaluated even inside sizeof, i.e. when nocode_wanted is set.
* Fix __builtin_constant_p(1000/x)Michael Matz2016-12-151-0/+10
| | | | | was incorrectly treated as constant because the vpop removed all traces of non-constness.
* tccasm: Support refs to anon symbols from asmMichael Matz2016-12-151-0/+23
| | | | | | | This happens when e.g. string constants (or other static data) are passed as operands to inline asm as immediates. The produced symbol ref wouldn't be found. So tighten the connection between C and asm-local symbol table even more.
* tccasm: Don't ignore # in preprocessor directivesMichael Matz2016-12-151-4/+17
| | | | | | | Our preprocessor throws away # line-comments in asm mode. It did so also inside preprocessor directives, thereby removing stringification. Parse defines in non-asm mode (but retain '.' as identifier character inside macro definitions).
* x86-asm: Accept all 32bit immediatesMichael Matz2016-12-151-0/+2
| | | | | In particular don't care if they're signed or unsigned, they're all acceptable as immediates.
* Fix enum bitfields passed to stdarg functionsMichael Matz2016-12-151-0/+5
| | | | | VT_ENUM types use the .ref member and can be VT_BITFIELD, so we need to copy it as well. Simply do it always.
* Addresses of non-weak symbols are non-zeroMichael Matz2016-12-151-0/+10
| | | | Use this fact in some foldings of comparisons. See testcase.
* Fix access-after-free with statement expressionsMichael Matz2016-12-151-0/+46
| | | | | | | | | | | | The return value of statement expressions might refer to local symbols, so those can't be popped. The old error message always was just a band-aid, and since disabling it for pointer types it wasn't effective anyway. It also never considered that also the vtop->sym member might have referred to such symbols (see the testcase with the local static, that used to segfault). For fixing this (can be seen better with valgrind and SYM_DEBUG) simply leave local symbols of stmt exprs on the stack.
* tccpp: Allow computed include like 42.hMichael Matz2016-12-152-3/+31
| | | | | | The include directive needs to be parsed as pp-tokens, not as token (i.e. no conversion to TOK_STR or TOK_NUM). Also fix parsing computed includes using quoted strings.
* x86-asm: Correctly infer register size for boolsMichael Matz2016-12-151-0/+10
| | | | | | Register operands of type _Bool weren't correctly getting the 8-bit sized registers (but rather used the default 32-bit ones).
* x86-64-asm: Implement cmpxchg16bMichael Matz2016-12-151-0/+3
|
* x86-64: Allow loads from some structs/unionsMichael Matz2016-12-151-0/+6
| | | | | | GCC allows register loads for asms based on type mode, and correctly sized structs/union have an allowed mode (basically 1,2,4,8 sized aggregates).
* tccasm: Lookup C symbols from ASM blocksMichael Matz2016-12-151-0/+28
| | | | | It's now possible to use symbols defined in C code to be used from later inline asm blocks. See testcase.
* tccasm: Implement .set sym, exprMichael Matz2016-12-151-0/+11
| | | | | | | | | | That, as well as "sym = expr", if expr contains symbols. Slightly tricky because a definition from .set is overridable, whereas proper definitions aren't. This doesn't yet allow using this for override tricks from C and global asm blocks because the symbol tables from C and asm are separate.
* enums and ints are compatibleMichael Matz2016-12-151-1/+1
| | | | | | | But like GCC do warn about changes in signedness. The latter leads to some changes in gen_assign_cast to not also warn about unsigned* = int* (where GCC warns, but only with extra warnings).
* enums and ints are compatibleMichael Matz2016-12-151-0/+2
|
* x86-64-asm: Fix ltr/str and push/pop operandsMichael Matz2016-12-151-0/+5
| | | | | str accepts rm16/r32/r64, and push/pop defaults to 64 when given memory operands (to 32 on i386).
* x86-64-asm: Implement high %cr registersMichael Matz2016-12-151-0/+2
|
* struct-init: Support range inits for local varsMichael Matz2016-12-152-0/+5
| | | | Implement missing support for range init for local variables.
* x86-64-asm: Support high registers %r8 - %r15Michael Matz2016-12-151-3/+37
| | | | | | | This requires correctly handling the REX prefix. As bonus we now also support the four 8bit registers spl,bpl,sil,dil, which are decoded as ah,ch,dh,bh in non-long-mode (and require a REX prefix as well).
* inline-asm: Accept "flags" clobberMichael Matz2016-12-151-1/+1
|
* struct-init: Allow member initialization from qualified lvaluesMichael Matz2016-12-152-3/+29
| | | | See testcase.
* struct-init: Correctly parse unnamed member initializersMichael Matz2016-12-152-0/+27
| | | | | | | | | | | | | For union U { struct {int a,b}; int c; }; union U u = {{ 1, 2, }}; The unnamed first member of union U needs to actually exist in the structure so initializer parsing isn't confused about the double braces. That means also the a and b members must be part of _that_, not of union U directly. Which in turn means we need to do a bit more work for field lookup. See the testcase extension for more things that need to work.
* struct-init: CleanupMichael Matz2016-12-153-1/+13
| | | | | | | Remove dead code and variables. Properly check for unions when skipping fields in initializers. Make tests2/*.expect depend on the .c files so they are automatically rebuilt when the latter change.
* struct-init: Implement initializing subaggregatesMichael Matz2016-12-153-1/+167
| | | | | | E.g. "struct { struct S s; int a;} = { others, 42 };" if 'others' is also a 'struct S'. Also when the value is a compound literal. See added testcases.
* 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-152-0/+16
| | | | | 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.
* x86-asm: Implement prefetchw opcodeMichael Matz2016-12-151-0/+1
|
* x86-asm: Fix lar opcode operandsMichael Matz2016-12-151-0/+7
| | | | | | | lar can accept multiple sizes as well (wlx), like lsl. When using autosize it's important to look at the destination operand first; when it's a register that one determines the size, not the input operand.
* x86-asm: More opcodesMichael Matz2016-12-151-0/+11
| | | | | Some new opcodes and some aliases: ljmp[wl], prefetch{nta,t0,t1,t2}, bswap[lq], sysretq, swapgs.
* x86-asm: Add [sl][ig]dtq opcodesMichael Matz2016-12-151-4/+10
| | | | | GAS has alias lgdtq for lgdt (similar for saves and GDT). It doesn't have the same for LDT.
* x86-asm: Implement fxrstorq and fxsaveqMichael Matz2016-12-151-0/+2
|
* 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).
* x86-asm: Implement clflush opcodeMichael Matz2016-12-151-0/+1
|
* 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.
* x86-64-asm: More opcodesMichael Matz2016-12-151-0/+7
| | | | Implement some more opcodes, syscall, sysret, lfence, mfence, sfence.
* tccasm: Implement compare expressionsMichael Matz2016-12-151-0/+6
| | | | | I.e. implement < > <= >= == !=. Comparisons are signed and result is -1 if true, 0 if false.
* x86-64-asm: Accept expressions for .quadMichael Matz2016-12-151-0/+1
| | | | | The x86-64 target has 64bit relocs, and hence can accept generic expressions for '.quad'.
* 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.
* tccasm: Accept .balignMichael Matz2016-12-151-0/+1
|
* Accept more asm expressionsMichael Matz2016-12-151-0/+13
| | | | | | In particular subtracting a defined symbol from current section makes the value PC relative, and .org accepts symbolic expressions as well, if the symbol is from the current section.
* tccasm: Implement .pushsection and .popsectionMichael Matz2016-12-151-0/+10
|
* 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.