Fix crash on error messages with unnamed objects

This commit is contained in:
drmortalwombat 2022-06-06 22:06:57 +02:00
parent 05ecc267ef
commit beb8d8e6d7
6 changed files with 25 additions and 25 deletions

View File

@ -108,7 +108,7 @@ void Compiler::RegisterRuntime(const Location & loc, const Ident* ident)
} }
else else
{ {
mErrors->Error(loc, EERR_RUNTIME_CODE, "Missing runtime code implementation", ident->mString); mErrors->Error(loc, EERR_RUNTIME_CODE, "Missing runtime code implementation", ident);
} }
} }

View File

@ -237,7 +237,7 @@ void GlobalAnalyzer::AnalyzeProcedure(Expression* exp, Declaration* dec)
Analyze(exp, dec); Analyze(exp, dec);
} }
else else
mErrors->Error(dec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", dec->mIdent->mString); mErrors->Error(dec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", dec->mIdent);
dec->mFlags &= ~DTF_FUNC_ANALYZING; dec->mFlags &= ~DTF_FUNC_ANALYZING;
} }

View File

@ -341,7 +341,7 @@ void InterCodeGenerator::TranslateAssembler(InterCodeModule* mod, Expression* ex
dec->mLinkerObject->AddReference(ref); dec->mLinkerObject->AddReference(ref);
} }
else else
mErrors->Error(aexp->mLocation, EERR_ASM_INVALD_OPERAND, "Undefined immediate operand", aexp->mBase->mIdent->mString); mErrors->Error(aexp->mLocation, EERR_ASM_INVALD_OPERAND, "Undefined immediate operand", aexp->mBase->mIdent);
} }
else if (aexp->mType == DT_VARIABLE_REF) else if (aexp->mType == DT_VARIABLE_REF)
{ {
@ -586,7 +586,7 @@ void InterCodeGenerator::TranslateAssembler(InterCodeModule* mod, Expression* ex
if (aexp->mBase->mBase) if (aexp->mBase->mBase)
d[offset] = aexp->mOffset + aexp->mBase->mInteger - offset - 1; d[offset] = aexp->mOffset + aexp->mBase->mInteger - offset - 1;
else else
mErrors->Error(aexp->mLocation, EERR_ASM_INVALD_OPERAND, "Undefined immediate operand", aexp->mBase->mIdent->mString); mErrors->Error(aexp->mLocation, EERR_ASM_INVALD_OPERAND, "Undefined immediate operand", aexp->mBase->mIdent);
} }
else else
d[offset] = aexp->mInteger - offset - 1; d[offset] = aexp->mInteger - offset - 1;
@ -2030,7 +2030,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
} }
else else
{ {
mErrors->Error(exp->mLeft->mDecValue->mLocation, EERR_OBJECT_NOT_FOUND, "Unknown intrinsic function", iname->mString); mErrors->Error(exp->mLeft->mDecValue->mLocation, EERR_OBJECT_NOT_FOUND, "Unknown intrinsic function", iname);
return ExValue(TheVoidTypeDeclaration); return ExValue(TheVoidTypeDeclaration);
} }
} }

View File

@ -426,7 +426,7 @@ void Linker::Link(void)
else if (obj->mFlags & LOBJF_REFERENCED) else if (obj->mFlags & LOBJF_REFERENCED)
{ {
if (!obj->mRegion) if (!obj->mRegion)
mErrors->Error(obj->mLocation, ERRR_INSUFFICIENT_MEMORY, "Could not place object", obj->mIdent->mString); mErrors->Error(obj->mLocation, ERRR_INSUFFICIENT_MEMORY, "Could not place object", obj->mIdent);
else if (obj->mRegion->mCartridgeBanks != 0) else if (obj->mRegion->mCartridgeBanks != 0)
{ {
for (int i = 0; i < 64; i++) for (int i = 0; i < 64; i++)

View File

@ -49,7 +49,7 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt)
} }
else else
{ {
mErrors->Error(mScanner->mLocation, EERR_DUPLICATE_DEFINITION, "Error duplicate struct declaration", structName->mString); mErrors->Error(mScanner->mLocation, EERR_DUPLICATE_DEFINITION, "Error duplicate struct declaration", structName);
} }
} }
} }
@ -92,7 +92,7 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt)
dec->mSize = offset; dec->mSize = offset;
if (dec->mScope->Insert(mdec->mIdent, mdec)) if (dec->mScope->Insert(mdec->mIdent, mdec))
mErrors->Error(mdec->mLocation, EERR_DUPLICATE_DEFINITION, "Duplicate struct member declaration", mdec->mIdent->mString); mErrors->Error(mdec->mLocation, EERR_DUPLICATE_DEFINITION, "Duplicate struct member declaration", mdec->mIdent);
if (mlast) if (mlast)
mlast->mNext = mdec; mlast->mNext = mdec;
@ -259,12 +259,12 @@ Declaration* Parser::ParseBaseTypeDeclaration(uint64 flags)
} }
else if (!dec) else if (!dec)
{ {
mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Identifier not defined", mScanner->mTokenIdent->mString); mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Identifier not defined", mScanner->mTokenIdent);
mScanner->NextToken(); mScanner->NextToken();
} }
else else
{ {
mErrors->Error(mScanner->mLocation, EERR_NOT_A_TYPE, "Identifier is no type", mScanner->mTokenIdent->mString); mErrors->Error(mScanner->mLocation, EERR_NOT_A_TYPE, "Identifier is no type", mScanner->mTokenIdent);
mScanner->NextToken(); mScanner->NextToken();
} }
break; break;
@ -706,7 +706,7 @@ Expression* Parser::ParseInitExpression(Declaration* dtype)
if (dtype->mType != DT_TYPE_ARRAY && !(dtype->mFlags & DTF_DEFINED)) if (dtype->mType != DT_TYPE_ARRAY && !(dtype->mFlags & DTF_DEFINED))
{ {
if (dtype->mIdent) if (dtype->mIdent)
mErrors->Error(mScanner->mLocation, EERR_UNDEFINED_OBJECT, "Constant for undefined type", dtype->mIdent->mString); mErrors->Error(mScanner->mLocation, EERR_UNDEFINED_OBJECT, "Constant for undefined type", dtype->mIdent);
else else
mErrors->Error(mScanner->mLocation, EERR_UNDEFINED_OBJECT, "Constant for undefined annonymous type"); mErrors->Error(mScanner->mLocation, EERR_UNDEFINED_OBJECT, "Constant for undefined annonymous type");
} }
@ -1054,7 +1054,7 @@ Declaration* Parser::ParseDeclaration(bool variable)
{ {
Declaration* pdec = mScope->Insert(ndec->mIdent, ndec->mBase); Declaration* pdec = mScope->Insert(ndec->mIdent, ndec->mBase);
if (pdec && pdec != ndec->mBase) if (pdec && pdec != ndec->mBase)
mErrors->Error(ndec->mLocation, EERR_DUPLICATE_DEFINITION, "Duplicate type declaration", ndec->mIdent->mString); mErrors->Error(ndec->mLocation, EERR_DUPLICATE_DEFINITION, "Duplicate type declaration", ndec->mIdent);
} }
} }
else else
@ -1083,7 +1083,7 @@ Declaration* Parser::ParseDeclaration(bool variable)
if (ndec->mType == DT_VARIABLE) if (ndec->mType == DT_VARIABLE)
ndec->mSection = mCompilationUnits->mSectionZeroPage; ndec->mSection = mCompilationUnits->mSectionZeroPage;
else else
mErrors->Error(ndec->mLocation, ERRR_INVALID_STORAGE_TYPE, "Invalid storage type", ndec->mIdent->mString); mErrors->Error(ndec->mLocation, ERRR_INVALID_STORAGE_TYPE, "Invalid storage type", ndec->mIdent);
} }
if (mGlobals == mScope && !(storageFlags & DTF_STATIC)) if (mGlobals == mScope && !(storageFlags & DTF_STATIC))
@ -1102,9 +1102,9 @@ Declaration* Parser::ParseDeclaration(bool variable)
if (pdec->mType == DT_CONST_FUNCTION && ndec->mBase->mType == DT_TYPE_FUNCTION) if (pdec->mType == DT_CONST_FUNCTION && ndec->mBase->mType == DT_TYPE_FUNCTION)
{ {
if (!ndec->mBase->IsSame(pdec->mBase)) if (!ndec->mBase->IsSame(pdec->mBase))
mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Function declaration differs", ndec->mIdent->mString); mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Function declaration differs", ndec->mIdent);
else if (ndec->mFlags & ~pdec->mFlags & (DTF_HWINTERRUPT | DTF_INTERRUPT | DTF_FASTCALL | DTF_NATIVE)) else if (ndec->mFlags & ~pdec->mFlags & (DTF_HWINTERRUPT | DTF_INTERRUPT | DTF_FASTCALL | DTF_NATIVE))
mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Function call type declaration differs", ndec->mIdent->mString); mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Function call type declaration differs", ndec->mIdent);
else else
{ {
// //
@ -1131,7 +1131,7 @@ Declaration* Parser::ParseDeclaration(bool variable)
else if (ndec->mBase->mType == DT_TYPE_POINTER && pdec->mBase->mType == DT_TYPE_ARRAY && ndec->mBase->mBase->IsSame(pdec->mBase->mBase)) else if (ndec->mBase->mType == DT_TYPE_POINTER && pdec->mBase->mType == DT_TYPE_ARRAY && ndec->mBase->mBase->IsSame(pdec->mBase->mBase))
; ;
else else
mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Variable declaration differs", ndec->mIdent->mString); mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Variable declaration differs", ndec->mIdent);
} }
ndec = pdec; ndec = pdec;
@ -1147,7 +1147,7 @@ Declaration* Parser::ParseDeclaration(bool variable)
pdec->mBase = ndec->mBase; pdec->mBase = ndec->mBase;
} }
else else
mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Variable declaration differs", ndec->mIdent->mString); mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Variable declaration differs", ndec->mIdent);
} }
if (!(ndec->mFlags & DTF_EXTERN)) if (!(ndec->mFlags & DTF_EXTERN))
@ -1159,7 +1159,7 @@ Declaration* Parser::ParseDeclaration(bool variable)
ndec = pdec; ndec = pdec;
} }
else else
mErrors->Error(ndec->mLocation, EERR_DUPLICATE_DEFINITION, "Duplicate variable declaration", ndec->mIdent->mString); mErrors->Error(ndec->mLocation, EERR_DUPLICATE_DEFINITION, "Duplicate variable declaration", ndec->mIdent);
} }
} }
@ -1475,13 +1475,13 @@ Expression* Parser::ParseSimpleExpression(void)
} }
else else
{ {
mErrors->Error(mScanner->mLocation, EERR_INVALID_IDENTIFIER, "Invalid identifier", mScanner->mTokenIdent->mString); mErrors->Error(mScanner->mLocation, EERR_INVALID_IDENTIFIER, "Invalid identifier", mScanner->mTokenIdent);
mScanner->NextToken(); mScanner->NextToken();
} }
} }
else else
{ {
mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Unknown identifier", mScanner->mTokenIdent->mString); mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Unknown identifier", mScanner->mTokenIdent);
mScanner->NextToken(); mScanner->NextToken();
} }
@ -1615,7 +1615,7 @@ Expression* Parser::ParsePostfixExpression(void)
exp = nexp->ConstantFold(mErrors); exp = nexp->ConstantFold(mErrors);
} }
else else
mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Struct member identifier not found", mScanner->mTokenIdent->mString); mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Struct member identifier not found", mScanner->mTokenIdent);
mScanner->NextToken(); mScanner->NextToken();
} }
else else
@ -1644,7 +1644,7 @@ Expression* Parser::ParsePostfixExpression(void)
exp = nexp->ConstantFold(mErrors); exp = nexp->ConstantFold(mErrors);
} }
else else
mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Struct member identifier not found", mScanner->mTokenIdent->mString); mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Struct member identifier not found", mScanner->mTokenIdent);
mScanner->NextToken(); mScanner->NextToken();
} }
else else
@ -2410,7 +2410,7 @@ Expression* Parser::ParseAssemblerBaseOperand(Declaration* pcasm, int pcoffset)
exp->mDecType = TheUnsignedIntTypeDeclaration; exp->mDecType = TheUnsignedIntTypeDeclaration;
} }
else else
mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Assembler label not found", mScanner->mTokenIdent->mString); mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Assembler label not found", mScanner->mTokenIdent);
} }
mScanner->NextToken(); mScanner->NextToken();
} }
@ -3583,7 +3583,7 @@ void Parser::ParsePragma(void)
mScanner->NextToken(); mScanner->NextToken();
ConsumeToken(TK_CLOSE_PARENTHESIS); ConsumeToken(TK_CLOSE_PARENTHESIS);
} }
mErrors->Error(mScanner->mLocation, EWARN_UNKNOWN_PRAGMA, "Unknown pragma, ignored", mScanner->mTokenIdent->mString); mErrors->Error(mScanner->mLocation, EWARN_UNKNOWN_PRAGMA, "Unknown pragma, ignored", mScanner->mTokenIdent);
} }
} }
else else

View File

@ -1878,7 +1878,7 @@ int64 Scanner::PrepParseSimple(void)
mErrors->Error(mLocation, ERRR_PREPROCESSOR, "'(' expected"); mErrors->Error(mLocation, ERRR_PREPROCESSOR, "'(' expected");
} }
else else
mErrors->Error(mLocation, ERRR_PREPROCESSOR, "Invalid preprocessor symbol", mTokenIdent->mString); mErrors->Error(mLocation, ERRR_PREPROCESSOR, "Invalid preprocessor symbol", mTokenIdent);
break; break;
default: default:
mErrors->Error(mLocation, ERRR_PREPROCESSOR, "Invalid preprocessor token", TokenName(mToken)); mErrors->Error(mLocation, ERRR_PREPROCESSOR, "Invalid preprocessor token", TokenName(mToken));