Fix crash in profile generation

This commit is contained in:
drmortalwombat 2025-05-04 13:12:14 +02:00
parent 5b961c031c
commit 18f044e90c
4 changed files with 33 additions and 1 deletions

View File

@ -651,6 +651,7 @@ Expression* ConstexprInterpreter::EvalConstructor(Expression* exp)
{
mProcType = exp->mLeft->mDecType;
Expression* pex = exp->mRight;
Declaration* cdec = exp->mLeft->mDecType->mParams;
int pos = 0;
@ -659,6 +660,28 @@ Expression* ConstexprInterpreter::EvalConstructor(Expression* exp)
mParams[pos].PutPtr(Value(&mResult));
pos = 2;
if (pex->mType == EX_LIST)
pex = pex->mRight;
else
pex = nullptr;
cdec = cdec->mNext;
while (pex && pex->mType == EX_LIST)
{
if (!AddParam(pos, pex->mLeft, cdec))
return exp;
pex = pex->mRight;
if (cdec)
cdec = cdec->mNext;
}
if (pex)
{
if (!AddParam(pos, pex, cdec))
return exp;
}
mHeap = new ExpandingArray<Value*>();
Execute(exp->mLeft->mDecValue->mValue);

View File

@ -2,6 +2,7 @@
#include "NumberSet.h"
class Location
{
public:
@ -12,7 +13,11 @@ public:
Location() : mFileName(nullptr), mLine(0), mColumn(0), mFrom(nullptr) {}
Location(const Location& loc, const Location* from)
: mFileName(loc.mFileName), mLine(loc.mLine), mColumn(loc.mColumn), mFrom(from)
{}
{
static volatile int k;
if (from)
k = from->mLine;
}
};
class Ident;

View File

@ -1912,6 +1912,7 @@ void InterCodeGenerator::CopyStruct(InterCodeProcedure* proc, Expression* exp, I
nmapper.mReturn = new InterCodeBasicBlock(proc);
nmapper.mVarIndex = proc->mNumLocals;
nmapper.mConstExpr = false;
nmapper.mLocation = new Location(MapLocation(exp, inlineMapper));
proc->mNumLocals += ccdec->mNumVars;
if (inlineMapper)
nmapper.mDepth = inlineMapper->mDepth + 1;

View File

@ -4644,6 +4644,9 @@ void Parser::ParseVariableInit(Declaration* ndec, Expression* pexp)
fexp = ResolveOverloadCall(fexp);
if ((fexp->mLeft->mDecValue->mFlags & DTF_CONSTEXPR) && ndec->mSection == mBSSection)
ndec->mSection = mDataSection;
Expression* dexp = nullptr;
if (ndec->mBase->mDestructor)
{