mirror of
git://repo.or.cz/tinycc.git
synced 2026-07-01 17:18:41 +08:00
Revert commits from OpenCode-AI and a partial regression fix
This reverts the crap from an unknown committer "OpenCode[AI]", that added an extension to TinyCC, which is incompatible to the C standard and not available in any other mainstream C compiler: * Revert "No More ; needed" This reverts commit6547ea47d6* Revert "Add AGENTS.md" This reverts commit898f496dc9. This also reverts a regression fix by "Zuhaitz.dev", which fixed a small part of the OpenCode-AI chaos: * Revert "tccgen: Fix optional semicolon regression" This reverts commit169628a6ab-- Regards ... Detlef
This commit is contained in:
parent
7b92d2dcd2
commit
9b8765d8ba
54
AGENTS.md
54
AGENTS.md
@ -1,54 +0,0 @@
|
|||||||
# TinyCC (Tiny C Compiler)
|
|
||||||
|
|
||||||
## Build & Test
|
|
||||||
|
|
||||||
```sh
|
|
||||||
./configure && make && make test
|
|
||||||
```
|
|
||||||
|
|
||||||
- `make` builds `tcc` + `libtcc.a` + `libtcc1.a`. `libtcc1.a` is built by a recursive `make -C lib`.
|
|
||||||
- `make test` runs the full test suite (`tests/`), ~2 minutes.
|
|
||||||
- Run a single tests2 test: `make tests2.37` (run) or `make tests2.37+` (update .expect).
|
|
||||||
- Run a single tests/pp test: `make testspp.17`.
|
|
||||||
- Sanitizer tests: `make sani-test`, `make sani-tests2.37`, `make sani-testspp.17`.
|
|
||||||
- Coverage tests: `make tcov-test`, `make tcov-tests2.37`, `make tcov-testspp.17`.
|
|
||||||
- Test installed tcc: `make test-install`.
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
- **Single-file-ish compiler**: tcc compiles itself (or can be bootstrapped). `tcc.c` is the main entrypoint; `tccpp.c` handles preprocessing, `tccgen.c` handles code generation, `tccelf.c` handles ELF linking, `tccasm.c` handles inline asm, `tccrun.c` handles runtime execution, `tccdbg.c` handles debug info.
|
|
||||||
- **Backend files per architecture**: `i386-gen.c`, `x86_64-gen.c`, `arm-gen.c`, `arm64-gen.c`, `riscv64-gen.c`, `c67-gen.c`, plus corresponding asm/link files.
|
|
||||||
- **Generated file**: `include/tccdefs.h` is converted to `tccdefs_.h` by `c2str.exe` (built from `conftest.c`). Always exists after first `make`.
|
|
||||||
- **Cross-compilers**: `make cross` builds all cross-compilers; `make cross-i386`, `make cross-x86_64`, etc. for one target. `make CROSS_TARGET=i386 ONE_SOURCE=yes` for single-object cross build.
|
|
||||||
- **`ONE_SOURCE=yes`**: builds tcc as a single object file (default for cross-compilers, native uses separate objects).
|
|
||||||
|
|
||||||
## Coding Style
|
|
||||||
|
|
||||||
- **C90** with these pre-existing non-C90 features: `long long`, `inline`, `//` comments, unnamed struct/union fields, empty macro arguments, assignment between function pointer and `void *`.
|
|
||||||
- **Indentation**: 4 spaces for most files; some files (e.g. `i386-gen.c`) use 2 spaces for deep nesting.
|
|
||||||
- **Do not reformat** existing code unless the change is the primary purpose.
|
|
||||||
- Remove tabs and trailing whitespace from modified lines.
|
|
||||||
- Check with `./configure --extra-cflags="-std=c90 -Wpedantic"`.
|
|
||||||
|
|
||||||
## Test Quirks
|
|
||||||
|
|
||||||
- `test.ref` (reference output) is generated from `tcctest.c` using gcc: `(cd tests && gcc -I.. tcctest.c && valgrind -q ./a.out > test.ref)` then `make test TCC="valgrind -q --leak-check=full $(pwd)/tcc -B$(pwd) -I$(pwd)"`.
|
|
||||||
- VLA tests (`79_vla_continue`) produce expected invalid reads under Valgrind.
|
|
||||||
- tests2 skip list is in `tests/tests2/Makefile` (architecture- and config-specific skips).
|
|
||||||
- Some tests need special flags (see `FLAGS =` assignments in `tests/tests2/Makefile`).
|
|
||||||
- Bound-check tests (`-b` flag) are skipped when `CONFIG_bcheck=no`.
|
|
||||||
- `.expect` files are generated with gcc by default; some use TCC (flagged with `GEN-TCC`).
|
|
||||||
|
|
||||||
## Language Extension: Optional Semicolons
|
|
||||||
|
|
||||||
Semicolons are optional after most statements and declarations:
|
|
||||||
- `return`, `break`, `continue`, `goto`, expression statements
|
|
||||||
- `do-while` trailing semicolon
|
|
||||||
- Variable declarations
|
|
||||||
|
|
||||||
Semicolons are still **required** for:
|
|
||||||
- `for()` loop init/condition/increment sections (e.g., `for(i=0; i<n; i++)`)
|
|
||||||
- Old-style function parameter declarations
|
|
||||||
- Struct/enum member declarations
|
|
||||||
|
|
||||||
The `skip(';')` function in `tccpp.c:100` errors if token doesn't match. Use `if (tok == ';') next();` instead to make semicolons optional.
|
|
||||||
21
tccgen.c
21
tccgen.c
@ -7205,7 +7205,7 @@ again:
|
|||||||
label_push(&local_label_stack, tok, LABEL_DECLARED);
|
label_push(&local_label_stack, tok, LABEL_DECLARED);
|
||||||
next();
|
next();
|
||||||
} while (tok == ',');
|
} while (tok == ',');
|
||||||
if (tok == ';') next();
|
skip(';');
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tok != '}') {
|
while (tok != '}') {
|
||||||
@ -7241,7 +7241,7 @@ again:
|
|||||||
leave_scope(root_scope);
|
leave_scope(root_scope);
|
||||||
if (b)
|
if (b)
|
||||||
gfunc_return(&func_vt);
|
gfunc_return(&func_vt);
|
||||||
if (tok == ';') next();
|
skip(';');
|
||||||
/* jump unless last stmt in top-level block */
|
/* jump unless last stmt in top-level block */
|
||||||
if (tok != '}' || local_scope != 1)
|
if (tok != '}' || local_scope != 1)
|
||||||
rsym = gjmp(rsym);
|
rsym = gjmp(rsym);
|
||||||
@ -7258,7 +7258,7 @@ again:
|
|||||||
else
|
else
|
||||||
leave_scope(loop_scope);
|
leave_scope(loop_scope);
|
||||||
*cur_scope->bsym = gjmp(*cur_scope->bsym);
|
*cur_scope->bsym = gjmp(*cur_scope->bsym);
|
||||||
if (tok == ';') next();
|
skip(';');
|
||||||
|
|
||||||
} else if (t == TOK_CONTINUE) {
|
} else if (t == TOK_CONTINUE) {
|
||||||
/* compute jump */
|
/* compute jump */
|
||||||
@ -7266,7 +7266,7 @@ again:
|
|||||||
tcc_error("cannot continue");
|
tcc_error("cannot continue");
|
||||||
leave_scope(loop_scope);
|
leave_scope(loop_scope);
|
||||||
*cur_scope->csym = gjmp(*cur_scope->csym);
|
*cur_scope->csym = gjmp(*cur_scope->csym);
|
||||||
if (tok == ';') next();
|
skip(';');
|
||||||
|
|
||||||
} else if (t == TOK_FOR) {
|
} else if (t == TOK_FOR) {
|
||||||
new_scope(&o);
|
new_scope(&o);
|
||||||
@ -7314,7 +7314,7 @@ again:
|
|||||||
gexpr();
|
gexpr();
|
||||||
c = gvtst(0, 0);
|
c = gvtst(0, 0);
|
||||||
skip(')');
|
skip(')');
|
||||||
if (tok == ';') next();
|
skip(';');
|
||||||
gsym_addr(c, d);
|
gsym_addr(c, d);
|
||||||
gsym(a);
|
gsym(a);
|
||||||
prev_scope_s(&o);
|
prev_scope_s(&o);
|
||||||
@ -7426,7 +7426,7 @@ again:
|
|||||||
} else {
|
} else {
|
||||||
expect("label identifier");
|
expect("label identifier");
|
||||||
}
|
}
|
||||||
if (tok == ';') next();
|
skip(';');
|
||||||
|
|
||||||
} else if (t == TOK_ASM1 || t == TOK_ASM2 || t == TOK_ASM3) {
|
} else if (t == TOK_ASM1 || t == TOK_ASM2 || t == TOK_ASM3) {
|
||||||
asm_instr();
|
asm_instr();
|
||||||
@ -7481,7 +7481,7 @@ again:
|
|||||||
gexpr();
|
gexpr();
|
||||||
vpop();
|
vpop();
|
||||||
}
|
}
|
||||||
if (tok == ';') next();
|
skip(';');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8637,7 +8637,7 @@ static void do_Static_assert(void)
|
|||||||
skip(')');
|
skip(')');
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
tcc_error("%s", msg);
|
tcc_error("%s", msg);
|
||||||
if (tok == ';') next();
|
skip(';');
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TCC_TARGET_PE
|
#ifdef TCC_TARGET_PE
|
||||||
@ -8904,10 +8904,7 @@ static int decl(int l)
|
|||||||
if (tok != ',') {
|
if (tok != ',') {
|
||||||
if (l == VT_JMP)
|
if (l == VT_JMP)
|
||||||
return has_init ? v : 1;
|
return has_init ? v : 1;
|
||||||
if (l == VT_CMP)
|
skip(';');
|
||||||
skip(';');
|
|
||||||
else if (tok == ';')
|
|
||||||
next();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
|
|||||||
@ -179,7 +179,7 @@ bar : 3 ; 3
|
|||||||
60_errors_and_warnings.c:372: error: statement expression outside of function
|
60_errors_and_warnings.c:372: error: statement expression outside of function
|
||||||
|
|
||||||
[test_invalid_tokckill]
|
[test_invalid_tokckill]
|
||||||
60_errors_and_warnings.c:375: warning: function might return no value: 'f'
|
60_errors_and_warnings.c:375: error: ';' expected (got '3')
|
||||||
|
|
||||||
[test_duplicate_member]
|
[test_duplicate_member]
|
||||||
60_errors_and_warnings.c:381: error: duplicate member 'a'
|
60_errors_and_warnings.c:381: error: duplicate member 'a'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user