Fixed array size template parameter
This commit is contained in:
parent
70eb7a5eab
commit
c86dc364b1
|
@ -2083,6 +2083,21 @@ bool Declaration::ResolveTemplate(Declaration* fdec, Declaration* tdec, bool sam
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
else if (tdec->mType == DT_TYPE_ARRAY && fdec->mType == DT_TYPE_ARRAY && tdec->mTemplate && tdec->mBase->IsConstSame(fdec->mBase))
|
||||||
|
{
|
||||||
|
Declaration* ifdec = new Declaration(fdec->mLocation, DT_CONST_INTEGER);
|
||||||
|
ifdec->mBase = TheSignedIntTypeDeclaration;
|
||||||
|
ifdec->mSize = 2;
|
||||||
|
ifdec->mInteger = fdec->mSize / fdec->mBase->mSize;
|
||||||
|
|
||||||
|
Declaration * ipdec = mScope->Insert(tdec->mTemplate->mIdent, ifdec);
|
||||||
|
if (ipdec && !ipdec->IsSame(ifdec))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (tdec->mType == DT_TYPE_STRUCT && fdec->mType == DT_TYPE_STRUCT && tdec->mTemplate)
|
else if (tdec->mType == DT_TYPE_STRUCT && fdec->mType == DT_TYPE_STRUCT && tdec->mTemplate)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1367,8 +1367,18 @@ Declaration* Parser::ParsePostfixDeclaration(void)
|
||||||
if (mScanner->mToken != TK_CLOSE_BRACKET)
|
if (mScanner->mToken != TK_CLOSE_BRACKET)
|
||||||
{
|
{
|
||||||
Expression* exp = ParseRExpression();
|
Expression* exp = ParseRExpression();
|
||||||
if (exp->mType == EX_CONSTANT && exp->mDecType->IsIntegerType() && exp->mDecValue->mType == DT_CONST_INTEGER)
|
if (exp->mType == EX_CONSTANT && exp->mDecType->IsIntegerType())
|
||||||
ndec->mSize = int(exp->mDecValue->mInteger);
|
{
|
||||||
|
if (exp->mDecValue->mType == DT_CONST_INTEGER)
|
||||||
|
ndec->mSize = int(exp->mDecValue->mInteger);
|
||||||
|
else if (exp->mDecValue->mType == DT_CONST_TEMPLATE)
|
||||||
|
{
|
||||||
|
ndec->mSize = 0;
|
||||||
|
ndec->mTemplate = exp->mDecValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mErrors->Error(exp->mLocation, EERR_CONSTANT_TYPE, "Constant integer expression expected");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mErrors->Error(exp->mLocation, EERR_CONSTANT_TYPE, "Constant integer expression expected");
|
mErrors->Error(exp->mLocation, EERR_CONSTANT_TYPE, "Constant integer expression expected");
|
||||||
ndec->mFlags |= DTF_DEFINED;
|
ndec->mFlags |= DTF_DEFINED;
|
||||||
|
@ -1505,7 +1515,7 @@ Declaration * Parser::ParseFunctionDeclaration(Declaration* bdec)
|
||||||
adec->mType = DT_ARGUMENT;
|
adec->mType = DT_ARGUMENT;
|
||||||
adec->mVarIndex = vi;
|
adec->mVarIndex = vi;
|
||||||
adec->mOffset = 0;
|
adec->mOffset = 0;
|
||||||
if (adec->mBase->mType == DT_TYPE_ARRAY)
|
if (adec->mBase->mType == DT_TYPE_ARRAY && !adec->mBase->mTemplate)
|
||||||
{
|
{
|
||||||
Declaration* ndec = new Declaration(adec->mBase->mLocation, DT_TYPE_POINTER);
|
Declaration* ndec = new Declaration(adec->mBase->mLocation, DT_TYPE_POINTER);
|
||||||
ndec->mBase = adec->mBase->mBase;
|
ndec->mBase = adec->mBase->mBase;
|
||||||
|
|
Loading…
Reference in New Issue