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; mProcType = exp->mLeft->mDecType;
Expression* pex = exp->mRight;
Declaration* cdec = exp->mLeft->mDecType->mParams; Declaration* cdec = exp->mLeft->mDecType->mParams;
int pos = 0; int pos = 0;
@ -659,6 +660,28 @@ Expression* ConstexprInterpreter::EvalConstructor(Expression* exp)
mParams[pos].PutPtr(Value(&mResult)); mParams[pos].PutPtr(Value(&mResult));
pos = 2; 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*>(); mHeap = new ExpandingArray<Value*>();
Execute(exp->mLeft->mDecValue->mValue); Execute(exp->mLeft->mDecValue->mValue);

View File

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

View File

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

View File

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