Fix more function overloads with const

This commit is contained in:
drmortalwombat 2025-05-08 15:21:59 +02:00
parent 34fda8c9b5
commit d0411b7d52
4 changed files with 27 additions and 6 deletions

View File

@ -206,7 +206,7 @@ protected:
template <class T>
void vector<T>::reserve(size_t n)
__noinline void vector<T>::reserve(size_t n)
{
if (n > _capacity)
{
@ -231,7 +231,7 @@ void vector<T>::clear(void)
}
template <class T>
void vector<T>::resize(size_t n)
__noinline void vector<T>::resize(size_t n)
{
if (n < _size)
{

View File

@ -2370,6 +2370,9 @@ Declaration* Declaration::ToConstType(void)
ndec->mSize = mSize;
ndec->mStride = mStride;
ndec->mStripe = mStripe;
if (mType == DT_TYPE_ARRAY)
ndec->mBase = mBase->ToConstType();
else
ndec->mBase = mBase;
ndec->mBits = mBits;
ndec->mShift = mShift;

View File

@ -6,7 +6,7 @@
#include "NumberSet.h"
Parser::Parser(Errors* errors, Scanner* scanner, CompilationUnits* compilationUnits)
: mErrors(errors), mScanner(scanner), mCompilationUnits(compilationUnits)
: mErrors(errors), mScanner(scanner), mCompilationUnits(compilationUnits), mParent(nullptr)
{
mGlobals = new DeclarationScope(compilationUnits->mScope, SLEVEL_STATIC);
mScope = mGlobals;
@ -5295,6 +5295,9 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
if (variable)
{
if (storageFlags & DTF_CONSTEXPR)
ndec->mBase = ndec->mBase->ToConstType();
ndec->mFlags |= storageFlags;
ndec->mFlags |= ndec->mBase->mFlags & (DTF_CONST | DTF_VOLATILE);
@ -7483,6 +7486,8 @@ int Parser::OverloadDistance(Declaration* fdec, Expression* pexp)
{
dist += 32;
}
else if (ptype->IsSimpleType() && etype->IsSimpleType() && ptype->IsConstSame(etype))
dist += 2;
else if (ptype->mType == DT_TYPE_STRUCT && etype->mType == DT_TYPE_STRUCT)
{
int ncast = 0;
@ -7870,7 +7875,7 @@ Expression * Parser::ResolveOverloadCall(Expression* exp, Expression* exp2)
fdec = fdec->mNext;
}
#endif
mErrors->Error(exp->mLocation, ERRO_NO_MATCHING_FUNCTION_CALL, "No matching function call", exp->mLeft->mDecValue->mQualIdent);
mErrors->Error(FullLocation(exp->mLocation), ERRO_NO_MATCHING_FUNCTION_CALL, "No matching function call", exp->mLeft->mDecValue->mQualIdent);
}
else if (nbest > 1)
{
@ -7882,7 +7887,7 @@ Expression * Parser::ResolveOverloadCall(Expression* exp, Expression* exp2)
fdec = fdec->mNext;
}
#endif
mErrors->Error(exp->mLocation, ERRO_AMBIGUOUS_FUNCTION_CALL, "Ambiguous function call", exp->mLeft->mDecValue->mQualIdent);
mErrors->Error(FullLocation(exp->mLocation), ERRO_AMBIGUOUS_FUNCTION_CALL, "Ambiguous function call", exp->mLeft->mDecValue->mQualIdent);
}
else
{
@ -11160,6 +11165,7 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
if (tmpld->mBase->mType == DT_TEMPLATE)
{
Parser* p = tmpld->mBase->mParser->Clone();
p->mParent = this;
p->mScanner->Replay(tmpld->mBase->mTokens);
@ -11450,6 +11456,7 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
#endif
Parser* p = tmpld->mParser->Clone();
p->mParent = this;
p->mScanner->Replay(tmpld->mTokens);
@ -14011,6 +14018,14 @@ void Parser::ParseNamespace(void)
}
}
Location Parser::FullLocation(const Location& loc)
{
if (mParent)
return mParent->FullLocation(Location(loc, &mParent->mScanner->mLocation));
else
return loc;
}
void Parser::Parse(void)
{
mLocalIndex = 0;

View File

@ -11,6 +11,7 @@ public:
~Parser(void);
Parser* Clone(void);
Parser * mParent;
DeclarationScope * mGlobals, * mScope, * mTemplateScope, * mCaptureScope;
int mLocalIndex;
@ -24,6 +25,8 @@ public:
uint64 mCompilerOptionStack[32];
int mCompilerOptionSP;
Location FullLocation(const Location& loc);
void Parse(void);
protected:
bool ExpectToken(Token token);