Fix removal of function reference result if only used as target
This commit is contained in:
parent
885d6ff706
commit
500cce511f
|
@ -1823,6 +1823,9 @@ bool Declaration::ResolveTemplateParameterList(Expression* pexp, Declaration* pd
|
||||||
{
|
{
|
||||||
if (pdec->mType == DT_PACK_ARGUMENT)
|
if (pdec->mType == DT_PACK_ARGUMENT)
|
||||||
{
|
{
|
||||||
|
if (preliminary)
|
||||||
|
return true;
|
||||||
|
|
||||||
Declaration* tpdec = new Declaration(pdec->mLocation, DT_PACK_TYPE);
|
Declaration* tpdec = new Declaration(pdec->mLocation, DT_PACK_TYPE);
|
||||||
if (pdec->mBase->mType == DT_TYPE_REFERENCE)
|
if (pdec->mBase->mType == DT_TYPE_REFERENCE)
|
||||||
tpdec->mIdent = pdec->mBase->mBase->mIdent;
|
tpdec->mIdent = pdec->mBase->mBase->mIdent;
|
||||||
|
@ -2120,7 +2123,19 @@ bool Declaration::ResolveTemplate(Declaration* fdec, Declaration* tdec, bool sam
|
||||||
tpdec = tpdec->mNext;
|
tpdec = tpdec->mNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !fpdec && !tpdec;
|
if (fpdec)
|
||||||
|
return false;
|
||||||
|
else if (!tpdec)
|
||||||
|
return true;
|
||||||
|
else if (tpdec->mBase->mType == DT_PACK_TEMPLATE)
|
||||||
|
{
|
||||||
|
Declaration*tppack = new Declaration(tpdec->mLocation, DT_PACK_TYPE);
|
||||||
|
Declaration* pdec = mScope->Insert(tpdec->mBase->mIdent, tppack);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ftdec = ftdec->mNext;
|
ftdec = ftdec->mNext;
|
||||||
|
|
|
@ -333,7 +333,7 @@ bool GlobalOptimizer::Optimize(void)
|
||||||
|
|
||||||
if (!(func->mOptFlags & OPTF_FUNC_VARIABLE) && !(func->mBase->mFlags & DTF_VIRTUAL))
|
if (!(func->mOptFlags & OPTF_FUNC_VARIABLE) && !(func->mBase->mFlags & DTF_VIRTUAL))
|
||||||
{
|
{
|
||||||
if (!(func->mOptFlags & OPTF_VAR_USED) && func->mBase->mBase && (func->mBase->mBase->IsSimpleType() || func->mBase->mBase->IsReference()))
|
if (!(func->mOptFlags & (OPTF_VAR_USED | OPTF_VAR_ADDRESS)) && func->mBase->mBase && (func->mBase->mBase->IsSimpleType() || func->mBase->mBase->IsReference()))
|
||||||
{
|
{
|
||||||
#if DUMP_OPTS
|
#if DUMP_OPTS
|
||||||
printf("Remove return value\n");
|
printf("Remove return value\n");
|
||||||
|
|
|
@ -10967,11 +10967,17 @@ void Parser::ParseTemplateArguments(Declaration* tmpld, Declaration* tdec)
|
||||||
{
|
{
|
||||||
ConsumeToken(TK_LESS_THAN);
|
ConsumeToken(TK_LESS_THAN);
|
||||||
|
|
||||||
Declaration* tparm = tmpld->mParams;
|
|
||||||
Declaration* ppdec = nullptr;
|
Declaration* ppdec = nullptr;
|
||||||
|
|
||||||
if (!ConsumeTokenIf(TK_GREATER_THAN))
|
if (!ConsumeTokenIf(TK_GREATER_THAN))
|
||||||
{
|
{
|
||||||
|
Declaration* tparm = tmpld->mParams;
|
||||||
|
while (tmpld->mNext && !tparm)
|
||||||
|
{
|
||||||
|
tmpld = tmpld->mNext;
|
||||||
|
tparm = tmpld->mParams;
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Expression* exp;
|
Expression* exp;
|
||||||
|
@ -11094,6 +11100,7 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
|
||||||
ParseTemplateArguments(tmpld, tdec);
|
ParseTemplateArguments(tmpld, tdec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Declaration* tmplpd = tmpld;
|
||||||
while (!tmpld->mTokens)
|
while (!tmpld->mTokens)
|
||||||
tmpld = tmpld->mNext;
|
tmpld = tmpld->mNext;
|
||||||
|
|
||||||
|
@ -11112,7 +11119,7 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
|
||||||
tdec->mQualIdent = tmpld->mQualIdent;
|
tdec->mQualIdent = tmpld->mQualIdent;
|
||||||
tdec->mScope->mName = tdec->mIdent;
|
tdec->mScope->mName = tdec->mIdent;
|
||||||
tdec->mNext = tmpld;
|
tdec->mNext = tmpld;
|
||||||
bdec->mIdent = tdec->MangleIdent();
|
bdec->mIdent = tdec->mIdent->Mangle(tdec->MangleIdent()->mString);
|
||||||
|
|
||||||
return bdec;
|
return bdec;
|
||||||
}
|
}
|
||||||
|
@ -11159,6 +11166,18 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
|
||||||
{
|
{
|
||||||
rdec = new Declaration(tdec->mLocation, DT_PACK_TYPE);
|
rdec = new Declaration(tdec->mLocation, DT_PACK_TYPE);
|
||||||
}
|
}
|
||||||
|
else if (!dec)
|
||||||
|
{
|
||||||
|
Declaration* packd = new Declaration(tdec->mLocation, DT_PACK_TEMPLATE);
|
||||||
|
packd->mBase = new Declaration(tdec->mLocation, DT_PACK_TYPE);
|
||||||
|
if (ppdec)
|
||||||
|
ppdec->mNext = packd;
|
||||||
|
else
|
||||||
|
tdec->mParams = packd;
|
||||||
|
|
||||||
|
ppdec = nullptr;
|
||||||
|
dec = packd;
|
||||||
|
}
|
||||||
else if (dec->mType != DT_PACK_TEMPLATE)
|
else if (dec->mType != DT_PACK_TEMPLATE)
|
||||||
{
|
{
|
||||||
Declaration* packd = new Declaration(dec->mLocation, DT_PACK_TEMPLATE);
|
Declaration* packd = new Declaration(dec->mLocation, DT_PACK_TEMPLATE);
|
||||||
|
@ -11186,6 +11205,11 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
|
||||||
dec = packd;
|
dec = packd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ppdec = dec;
|
||||||
|
dec = dec->mNext;
|
||||||
|
}
|
||||||
|
|
||||||
if (rdec)
|
if (rdec)
|
||||||
{
|
{
|
||||||
|
@ -11335,6 +11359,7 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
|
||||||
|
|
||||||
p->mScanner->Replay(tmpld->mTokens);
|
p->mScanner->Replay(tmpld->mTokens);
|
||||||
|
|
||||||
|
tdec->mIdent = tmpld->mIdent;
|
||||||
tdec->mScope->mName = tdec->MangleIdent();
|
tdec->mScope->mName = tdec->MangleIdent();
|
||||||
tdec->mNext = tmpld->mNext;
|
tdec->mNext = tmpld->mNext;
|
||||||
tmpld->mNext = tdec;
|
tmpld->mNext = tdec;
|
||||||
|
|
Loading…
Reference in New Issue