History

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.

grischka committed 16 years ago

Commit 4ab4efd1 parent 7901d1e1 file · +4 −37Browse files

Unified · Split

tccgen.c+4−37
@@ -4291,28 +4291,14 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 4290 unmodified lines
42914291 next();
42924292 skip(';');
42934293 } else if (tok == TOK_FOR) {
4294− int e, c99_for_decl = 0;
4294+ int e;
42954295 next();
42964296 skip('(');
42974297 if (tok != ';') {
4298− if (tok < TOK_UIDENT) {
4299− // handle C99 for loop construct
4300− c99_for_decl = 1;
4301−
4302− /* record local declaration stack position */
4303− s = local_stack;
4304−
4305− decl(VT_LOCAL);
4306− if (is_expr)
4307− vpop();
4308− } else {
4309− gexpr();
4310− vpop();
4311− skip(';');
4312− }
4313− } else {
4314− skip(';');
4298+ gexpr();
4299+ vpop();
43154300 }
4301+ skip(';');
43164302 d = ind;
43174303 c = ind;
43184304 a = 0;
@@ -4335,25 +4321,6 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 16 unmodified lines
43354321 gjmp_addr(c);
43364322 gsym(a);
43374323 gsym_addr(b, c);
4338−
4339− if (c99_for_decl) {
4340− /* pop locally defined symbols */
4341− if(is_expr) {
4342− /* XXX: this solution makes only valgrind happy...
4343− triggered by gcc.c-torture/execute/20000917-1.c */
4344− Sym *p;
4345− switch(vtop->type.t & VT_BTYPE) {
4346− case VT_PTR:
4347− case VT_STRUCT:
4348− case VT_ENUM:
4349− case VT_FUNC:
4350− for(p=vtop->type.ref;p;p=p->prev)
4351− if(p->prev==s)
4352− error("unsupported expression type");
4353− }
4354− }
4355− sym_pop(&local_stack, s);
4356− }
43574324 } else
43584325 if (tok == TOK_DO) {
43594326 next();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t