On 18.01.2024 17:38, Herman ten Brugge via Tinycc-devel wrote:
That depends on the version of gcc / clang.
Gcc 13.2.1 prints no error.
Clang 17.0.6 prints "error: expected expression"
Clang 18.0.0(not released yet) prints "warning: label followed by a
declaration is a C23 extension [-Wc23-extensions]"
I probably should have mentioned it when committing the fix.
Maybe yes.
Plus mention that it's not a fix, but an experiment
with undocumented non-standard syntax.
Plus mention the benefit and the price too, please.
Plus while at it, spend some thoughts first:
- } else {
+ } else if (!decl(VT_JMP)) {
gexpr();
vpop();
Hm... just one line changed. But wait, does not tcc look
for decl before expression already? Sure it does because
it supports C99. Why now look twice ? And why skip parsing
the expression if where was a declaration? What's the point?
Who wrote that?
Let's maybe try to use the tcov for tcc (which as we know was
you who wrote it and is really not bad btw):
$ tcc -ftest-coverage ../tcc.c -o tcc1.exe && tcc1.exe ../tcc.c -o
tcc2.exe
tcc1.exe.tcov:
-: 0:Function:decl 68.67%
Before:
10701: 8417: int v, has_init, r, oldint;
After:
18408: 8417: int v, has_init, r, oldint;
We note 7707 additional (+72%) calls for decl(),
183: 7247: block_after_label:
1006: 7248: {
and that however only 1006 labels/cases/defaults were seen
at all.
Also we note no "label: decl" in tcc anywhere and also in
noone elses code we've seen so far (the OP's doesn't count
because it's generated C IIUC)
Now back to the "benefit vs. price" question ...