Fix const enum type check
This commit is contained in:
parent
04624f208c
commit
44bd9cf595
|
@ -639,9 +639,9 @@ bool Declaration::IsSubType(const Declaration* dec) const
|
|||
return true;
|
||||
else if (mType == DT_TYPE_BOOL || mType == DT_TYPE_FLOAT || mType == DT_TYPE_VOID)
|
||||
return true;
|
||||
else if (mType == DT_TYPE_STRUCT)
|
||||
else if (mType == DT_TYPE_STRUCT || mType == DT_TYPE_ENUM)
|
||||
return mScope == dec->mScope || (mIdent == dec->mIdent && mSize == dec->mSize);
|
||||
else if (mType == DT_TYPE_STRUCT || mType == DT_TYPE_ENUM || mType == DT_TYPE_UNION)
|
||||
else if (mType == DT_TYPE_UNION)
|
||||
return false;
|
||||
else if (mType == DT_TYPE_ARRAY)
|
||||
return mSize <= dec->mSize && mBase->IsSubType(dec->mBase);
|
||||
|
|
|
@ -277,6 +277,7 @@ Declaration* Parser::ParseBaseTypeDeclaration(uint64 flags)
|
|||
dec = new Declaration(mScanner->mLocation, DT_TYPE_ENUM);
|
||||
dec->mFlags = flags;
|
||||
dec->mSize = 1;
|
||||
dec->mScope = new DeclarationScope(nullptr);
|
||||
|
||||
mScanner->NextToken();
|
||||
if (mScanner->mToken == TK_IDENT)
|
||||
|
@ -635,7 +636,10 @@ Declaration * Parser::CopyConstantInitializer(int offset, Declaration* dtype, Ex
|
|||
dec->mOffset = offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
dtype->CanAssign(exp->mDecType);
|
||||
mErrors->Error(exp->mLocation, EERR_CONSTANT_INITIALIZER, "Incompatible constant initializer");
|
||||
}
|
||||
}
|
||||
else
|
||||
mErrors->Error(exp->mLocation, EERR_CONSTANT_INITIALIZER, "Constant initializer expected");
|
||||
|
|
Loading…
Reference in New Issue