Fix some local declarations not working.

This commit is contained in:
David Anderson
2014-07-04 23:53:16 -07:00
parent 9a2bdd3792
commit f62769108c
3 changed files with 35 additions and 14 deletions
+24
View File
@@ -3361,6 +3361,8 @@ static int reparse_new_decl(declinfo_t *decl, int flags)
decl->type.numdim = 0;
decl->type.size = 0;
decl->type.enumroot = NULL;
decl->type.ident = iVARIABLE;
decl->type.size = 0;
decl->has_postdims = FALSE;
if (matchtoken('['))
parse_old_array_dims(decl, flags);
@@ -6461,6 +6463,28 @@ static void statement(int *lastindent,int allow_decl)
*lastindent=stmtindent;
indent_nowarn=FALSE; /* if warning was blocked, re-enable it */
} /* if */
if (tok == tSYMBOL) {
// We reaaaally don't have enough lookahead for this, so we cheat and try
// to determine whether this is probably a declaration.
int is_decl = FALSE;
if (matchtoken('[')) {
if (lexpeek(']'))
is_decl = TRUE;
lexpush();
} else if (lexpeek(tSYMBOL)) {
is_decl = TRUE;
}
if (is_decl) {
lexpush();
autozero = TRUE;
lastst = tNEW;
declloc(tNEW);
return;
}
}
switch (tok) {
case 0:
/* nothing */
-4
View File
@@ -2319,10 +2319,6 @@ SC_FUNC int matchtoken(int token)
*/
SC_FUNC int tokeninfo(cell *val,char **str)
{
/* if the token was pushed back, tokeninfo() returns the token and
* parameters of the *next* token, not of the *current* token.
*/
assert(sTokenBuffer->depth == 0);
*val = current_token()->value;
*str = current_token()->str;
return current_token()->id;