aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorgrischka <grischka>2010-08-21 13:39:12 +0200
committergrischka <grischka>2010-08-21 13:39:12 +0200
commit4ab4efd3a69e0e10262b3010aa9162e73b1cddfb (patch)
treed35348f9c6f3ac92a81de70b96c5dd41c1a4117e /tccgen.c
parent7901d1e3ad19b630c39388612a5ad7c0bf84df39 (diff)
downloadtinycc-4ab4efd3a69e0e10262b3010aa9162e73b1cddfb.tar.gz
tinycc-4ab4efd3a69e0e10262b3010aa9162e73b1cddfb.tar.bz2
Revert "implemented C99 for loop with variable declaration"
This reverts commit 433ecdfc9d1402ecf03e710de481e2063ad6de90. The patch breaks e.g. with for ((i = 10); --i;); In particular to check for a type decl. this is not sufficient: if (tok < TOK_UIDENT) { A future approach to c99 loop variables might instead use: if (parse_btype(...)) { plus refactor function decl() accordingly.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c41
1 files changed, 4 insertions, 37 deletions
diff --git a/tccgen.c b/tccgen.c
index a7c9557..7d7cafc 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -4291,28 +4291,14 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
next();
skip(';');
} else if (tok == TOK_FOR) {
- int e, c99_for_decl = 0;
+ int e;
next();
skip('(');
if (tok != ';') {
- if (tok < TOK_UIDENT) {
- // handle C99 for loop construct
- c99_for_decl = 1;
-
- /* record local declaration stack position */
- s = local_stack;
-
- decl(VT_LOCAL);
- if (is_expr)
- vpop();
- } else {
- gexpr();
- vpop();
- skip(';');
- }
- } else {
- skip(';');
+ gexpr();
+ vpop();
}
+ skip(';');
d = ind;
c = ind;
a = 0;
@@ -4335,25 +4321,6 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
gjmp_addr(c);
gsym(a);
gsym_addr(b, c);
-
- if (c99_for_decl) {
- /* pop locally defined symbols */
- if(is_expr) {
- /* XXX: this solution makes only valgrind happy...
- triggered by gcc.c-torture/execute/20000917-1.c */
- Sym *p;
- switch(vtop->type.t & VT_BTYPE) {
- case VT_PTR:
- case VT_STRUCT:
- case VT_ENUM:
- case VT_FUNC:
- for(p=vtop->type.ref;p;p=p->prev)
- if(p->prev==s)
- error("unsupported expression type");
- }
- }
- sym_pop(&local_stack, s);
- }
} else
if (tok == TOK_DO) {
next();