From 92de4fa0d0f8ae1c4d863a7191037bd0dea8cc0b Mon Sep 17 00:00:00 2001 From: acqn Date: Wed, 29 Jul 2020 15:08:54 +0800 Subject: [PATCH] Enabled to recognize labels when parsing local variable declarations. --- src/cc65/declare.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 5c5c5c01e..1ebae4123 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -1248,11 +1248,23 @@ static void ParseTypeSpec (DeclSpec* D, long Default, TypeCode Qualifiers) break; case TOK_IDENT: - Entry = FindSym (CurTok.Ident); - if (Entry && SymIsTypeDef (Entry)) { - /* It's a typedef */ - NextToken (); - TypeCopy (D->Type, Entry->Type); + /* This could be a label */ + if (NextTok.Tok != TOK_COLON) { + Entry = FindSym (CurTok.Ident); + if (Entry && SymIsTypeDef (Entry)) { + /* It's a typedef */ + NextToken (); + TypeCopy (D->Type, Entry->Type); + break; + } + } else { + /* This is a label. Use the default type flag to end the loop + ** in DeclareLocals. The type code used here doesn't matter as + ** long as it has no qualifiers. + */ + D->Flags |= DS_DEF_TYPE; + D->Type[0].C = T_QUAL_NONE; + D->Type[1].C = T_END; break; } /* FALL THROUGH */