History

Display error on statement expressions with complex return type

The return type of a statement expression (a GCC extention) may involve elements on the symbol stack that have been put there by the expression. These will be freed at the end of the expression so that the calling block can not use them. Contrary to the comment (written in 2003), this bug no longer shows up in Valgrind, as freed symbols are now put onto a stack for later reuse.

Daniel Glöckner committed 18 years ago

Commit a80acab1 parent 3783b331 file · +14 −0Browse files

Unified · Split

tcc.c+14−0
@@ -8275,6 +8275,20 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 8274 unmodified lines
8275 /* pop locally defined labels */8275 /* pop locally defined labels */
8276 label_pop(&local_label_stack, llabel);8276 label_pop(&local_label_stack, llabel);
8277 /* pop locally defined symbols */8277 /* pop locally defined symbols */
8278 if(is_expr) {
8279 /* XXX: this solution makes only valgrind happy...
8280 triggered by gcc.c-torture/execute/20000917-1.c */
8281 Sym *p;
8282 switch(vtop->type.t & VT_BTYPE) {
8283 case VT_PTR:
8284 case VT_STRUCT:
8285 case VT_ENUM:
8286 case VT_FUNC:
8287 for(p=vtop->type.ref;p;p=p->prev)
8288 if(p->prev==s)
8289 error("unsupported expression type");
8290 }
8291 }
8278 sym_pop(&local_stack, s);8292 sym_pop(&local_stack, s);
8279 next();8293 next();
8280 } else if (tok == TOK_RETURN) {8294 } else if (tok == TOK_RETURN) {

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