Mercurial > hg > qcc
changeset 400:afda44bbf76b
Bugfix from Dave Dodge: tcc doesn't properly handle the following construct:
typedef [...] a;
typedef [...] b;
[...] foo([...])
{
a b; /* not parsed correctly */
}
The problem is that it parses both "a" and "b" as typedef names, and
does nothing as a result. Although the C99 grammar allows this
parsing, there is a constraint in the narrative that invalidates it
and requires "b" to be treated as a declarator. This patch causes tcc
to stop looking for typedef names in a declaration specifier list
after it finds the first one; the end result should be that "b"
becomes a local variable and hides the "b" typedef while in scope.
author | landley@driftwood |
---|---|
date | Sun, 08 Oct 2006 01:13:34 -0400 |
parents | 79cb0d585837 |
children | 2707893d0c57 |
files | tcc.c |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tcc.c Sun Oct 08 01:06:44 2006 -0400 +++ b/tcc.c Sun Oct 08 01:13:34 2006 -0400 @@ -6660,13 +6660,14 @@ */ static int parse_btype(CType *type, AttributeDef *ad) { - int t, u, type_found, typespec_found; + int t, u, type_found, typespec_found, typedef_found; Sym *s; CType type1; memset(ad, 0, sizeof(AttributeDef)); type_found = 0; typespec_found = 0; + typedef_found = 0; t = 0; while(1) { switch(tok) { @@ -6799,11 +6800,12 @@ parse_expr_type(&type1); goto basic_type2; default: - if (typespec_found) + if (typespec_found || typedef_found) goto the_end; s = sym_find(tok); if (!s || !(s->type.t & VT_TYPEDEF)) goto the_end; + typedef_found = 1; t |= (s->type.t & ~VT_TYPEDEF); type->ref = s->type.ref; next();