mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Const resolve enum case cast fix
This commit is contained in:
parent
f830e23c52
commit
53f4e8955e
4 changed files with 17 additions and 2 deletions
|
@ -1135,7 +1135,10 @@ void BeIRCodeGen::Read(BeMDNode*& llvmMD)
|
|||
void BeIRCodeGen::HandleNextCmd()
|
||||
{
|
||||
if (mFailed)
|
||||
{
|
||||
mStream->SetReadPos(mStream->GetSize());
|
||||
return;
|
||||
}
|
||||
|
||||
int curId = mCmdCount;
|
||||
|
||||
|
@ -2318,7 +2321,11 @@ void BeIRCodeGen::HandleNextCmd()
|
|||
CMD_PARAM(BeValue*, value);
|
||||
CMD_PARAM(BeBlock*, comingFrom);
|
||||
|
||||
BF_ASSERT(phiValue->GetType() == value->GetType());
|
||||
if (phiValue->GetType() != value->GetType())
|
||||
{
|
||||
Fail("AddPhiIncoming type mismatch");
|
||||
break;
|
||||
}
|
||||
|
||||
auto phiIncoming = mBeModule->mAlloc.Alloc<BePhiIncoming>();
|
||||
phiIncoming->mBlock = comingFrom;
|
||||
|
|
|
@ -167,7 +167,10 @@ BfTypedValue BfConstResolver::Resolve(BfExpression* expr, BfType* wantType, BfCo
|
|||
}
|
||||
else
|
||||
{
|
||||
mResult = mModule->Cast(expr, mResult, wantType, (BfCastFlags)(BfCastFlags_WantsConst | (explicitCast ? BfCastFlags_Explicit : BfCastFlags_None)));
|
||||
BfCastFlags castFlags = (BfCastFlags)(BfCastFlags_WantsConst | (explicitCast ? BfCastFlags_Explicit : BfCastFlags_None));
|
||||
if ((flags & BfConstResolveFlag_NoConversionOperator) != 0)
|
||||
castFlags = (BfCastFlags)(castFlags | BfCastFlags_NoConversionOperator);
|
||||
mResult = mModule->Cast(expr, mResult, wantType, castFlags);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ enum BfConstResolveFlags
|
|||
BfConstResolveFlag_NoActualizeValues = 0x10,
|
||||
BfConstResolveFlag_ArrayInitSize = 0x20,
|
||||
BfConstResolveFlag_AllowGlobalVariable = 0x40,
|
||||
BfConstResolveFlag_NoConversionOperator = 0x80
|
||||
};
|
||||
|
||||
class BfConstResolver : public BfExprEvaluator
|
||||
|
|
|
@ -4679,6 +4679,10 @@ BfTypedValue BfModule::GetFieldInitializerValue(BfFieldInstance* fieldInstance,
|
|||
// auto-created underlying type and it will cause an 'error flash'. We defer errors until the full resolve for that purpose
|
||||
resolveFlags = BfConstResolveFlag_NoCast;
|
||||
}
|
||||
|
||||
if ((mCurTypeInstance->IsEnum()) && (fieldDef->IsEnumCaseEntry()))
|
||||
resolveFlags = (BfConstResolveFlags)(resolveFlags | BfConstResolveFlag_NoConversionOperator | BfConstResolveFlag_ExplicitCast);
|
||||
|
||||
UpdateSrcPos(initializer);
|
||||
auto result = constResolver.Resolve(initializer, fieldType, resolveFlags);
|
||||
if ((mCompiler->mCeMachine != NULL) && (fieldInstance != NULL))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue