Fix error message for undefined identifier in case statement

This commit is contained in:
drmortalwombat 2024-08-27 08:05:28 +02:00
parent 8fbe96b9ac
commit f38b366d81
2 changed files with 8 additions and 8 deletions

View File

@ -3794,7 +3794,7 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
mScanner->NextToken(); mScanner->NextToken();
if (ConsumeTokenIf(TK_NAMESPACE)) if (ConsumeTokenIf(TK_NAMESPACE))
{ {
Declaration* dec = ParseQualIdent(); Declaration* dec = ParseQualIdent(true);
if (dec) if (dec)
{ {
if (dec->mType == DT_NAMESPACE) if (dec->mType == DT_NAMESPACE)
@ -3812,7 +3812,7 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
} }
else if (ConsumeTokenIf(TK_ENUM)) else if (ConsumeTokenIf(TK_ENUM))
{ {
Declaration* dec = ParseQualIdent(); Declaration* dec = ParseQualIdent(false);
if (dec) if (dec)
{ {
if (dec->mType == DT_TYPE_ENUM) if (dec->mType == DT_TYPE_ENUM)
@ -3833,7 +3833,7 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
Declaration* dec; Declaration* dec;
do { do {
dec = ParseQualIdent(); dec = ParseQualIdent(false);
if (dec) if (dec)
{ {
Declaration* pdec = mScope->Insert(dec->mIdent, dec); Declaration* pdec = mScope->Insert(dec->mIdent, dec);
@ -4992,7 +4992,7 @@ Expression* Parser::ParseDeclarationExpression(Declaration * pdec)
return exp; return exp;
} }
Declaration* Parser::ParseQualIdent(void) Declaration* Parser::ParseQualIdent(bool lhs)
{ {
Declaration* dec = nullptr; Declaration* dec = nullptr;
if (mTemplateScope) if (mTemplateScope)
@ -5037,7 +5037,7 @@ Declaration* Parser::ParseQualIdent(void)
const Ident* ident = mScanner->mTokenIdent; const Ident* ident = mScanner->mTokenIdent;
Location loc = mScanner->mLocation; Location loc = mScanner->mLocation;
mScanner->NextToken(); mScanner->NextToken();
if (ConsumeTokenIf(TK_COLON)) if (lhs && ConsumeTokenIf(TK_COLON))
{ {
dec = new Declaration(loc, DT_CLABEL); dec = new Declaration(loc, DT_CLABEL);
dec->mIdent = ident; dec->mIdent = ident;
@ -5642,7 +5642,7 @@ Expression* Parser::ParseSimpleExpression(bool lhs, bool tid)
if (!exp) if (!exp)
{ {
if (!dec) if (!dec)
dec = ParseQualIdent(); dec = ParseQualIdent(lhs);
if (dec) if (dec)
{ {
if (dec->mTemplate && mScanner->mToken == TK_LESS_THAN) if (dec->mTemplate && mScanner->mToken == TK_LESS_THAN)
@ -12331,7 +12331,7 @@ void Parser::ParseNamespace(void)
else else
{ {
ConsumeToken(TK_ASSIGN); ConsumeToken(TK_ASSIGN);
Declaration* dec = ParseQualIdent(); Declaration* dec = ParseQualIdent(false);
if (dec) if (dec)
{ {
if (dec->mType == DT_NAMESPACE) if (dec->mType == DT_NAMESPACE)

View File

@ -90,7 +90,7 @@ protected:
void AddAssemblerRegister(const Ident* ident, int value); void AddAssemblerRegister(const Ident* ident, int value);
Declaration* ParseQualIdent(void); Declaration* ParseQualIdent(bool lhs);
void SkipStatement(void); void SkipStatement(void);
Expression* ParseStatement(void); Expression* ParseStatement(void);