diff options
| author | Daniel Glöckner <daniel-gl@gmx.net> | 2008-09-11 21:04:22 +0200 |
|---|---|---|
| committer | grischka <grischka> | 2008-09-12 22:23:02 +0200 |
| commit | a80acab4fc15c3df6c062191d486518645557d2e (patch) | |
| tree | 3b79641bdcf5dc939fc1473ebf39d45404ac6aa6 /tcc.c | |
| parent | 3783b335084ef69447c8703c7b9a94687d80b1cb (diff) | |
| download | tinycc-a80acab4fc15c3df6c062191d486518645557d2e.tar.gz tinycc-a80acab4fc15c3df6c062191d486518645557d2e.tar.bz2 | |
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.
Diffstat (limited to 'tcc.c')
| -rw-r--r-- | tcc.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -8275,6 +8275,20 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, /* pop locally defined labels */ label_pop(&local_label_stack, llabel); /* 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); next(); } else if (tok == TOK_RETURN) { |
