Fix const struct parameter overload matching
This commit is contained in:
parent
b4a357e44f
commit
34fda8c9b5
|
@ -31,6 +31,17 @@ DeclarationScope::~DeclarationScope(void)
|
|||
delete[] mHash;
|
||||
}
|
||||
|
||||
DeclarationScope* DeclarationScope::Clone(void) const
|
||||
{
|
||||
DeclarationScope* scope = new DeclarationScope(mParent, mLevel, mName);
|
||||
for (int i = 0; i < mHashSize; i++)
|
||||
{
|
||||
if (mHash[i].mIdent)
|
||||
scope->Insert(mHash[i].mIdent, mHash[i].mDec);
|
||||
}
|
||||
return scope;
|
||||
}
|
||||
|
||||
const Ident* DeclarationScope::Mangle(const Ident* ident) const
|
||||
{
|
||||
if (mName && ident)
|
||||
|
|
|
@ -166,6 +166,8 @@ public:
|
|||
ScopeLevel mLevel;
|
||||
const Ident * mName;
|
||||
|
||||
DeclarationScope* Clone(void) const;
|
||||
|
||||
DeclarationScope* mParent;
|
||||
protected:
|
||||
struct Entry
|
||||
|
|
|
@ -7483,6 +7483,21 @@ int Parser::OverloadDistance(Declaration* fdec, Expression* pexp)
|
|||
{
|
||||
dist += 32;
|
||||
}
|
||||
else if (ptype->mType == DT_TYPE_STRUCT && etype->mType == DT_TYPE_STRUCT)
|
||||
{
|
||||
int ncast = 0;
|
||||
Declaration* ext = ex->mDecType;
|
||||
while (ext && !ext->IsConstSame(ptype))
|
||||
{
|
||||
ncast++;
|
||||
ext = ext->mBase;
|
||||
}
|
||||
|
||||
if (ext)
|
||||
dist += 32 * ncast;
|
||||
else
|
||||
return NOOVERLOAD;
|
||||
}
|
||||
else
|
||||
return NOOVERLOAD;
|
||||
|
||||
|
@ -11149,6 +11164,7 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
|
|||
p->mScanner->Replay(tmpld->mBase->mTokens);
|
||||
|
||||
tdec = tmpld->mBase->Clone();
|
||||
tdec->mScope = tdec->mScope->Clone();
|
||||
tdec->mScope->mName = expd->mScope->mName;
|
||||
tdec->mScope->mParent = expd->mScope;
|
||||
|
||||
|
|
Loading…
Reference in New Issue