Fix more function overloads with const
This commit is contained in:
parent
34fda8c9b5
commit
d0411b7d52
|
@ -206,7 +206,7 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void vector<T>::reserve(size_t n)
|
__noinline void vector<T>::reserve(size_t n)
|
||||||
{
|
{
|
||||||
if (n > _capacity)
|
if (n > _capacity)
|
||||||
{
|
{
|
||||||
|
@ -231,7 +231,7 @@ void vector<T>::clear(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void vector<T>::resize(size_t n)
|
__noinline void vector<T>::resize(size_t n)
|
||||||
{
|
{
|
||||||
if (n < _size)
|
if (n < _size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2370,7 +2370,10 @@ Declaration* Declaration::ToConstType(void)
|
||||||
ndec->mSize = mSize;
|
ndec->mSize = mSize;
|
||||||
ndec->mStride = mStride;
|
ndec->mStride = mStride;
|
||||||
ndec->mStripe = mStripe;
|
ndec->mStripe = mStripe;
|
||||||
ndec->mBase = mBase;
|
if (mType == DT_TYPE_ARRAY)
|
||||||
|
ndec->mBase = mBase->ToConstType();
|
||||||
|
else
|
||||||
|
ndec->mBase = mBase;
|
||||||
ndec->mBits = mBits;
|
ndec->mBits = mBits;
|
||||||
ndec->mShift = mShift;
|
ndec->mShift = mShift;
|
||||||
ndec->mFlags = mFlags | DTF_CONST;
|
ndec->mFlags = mFlags | DTF_CONST;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "NumberSet.h"
|
#include "NumberSet.h"
|
||||||
|
|
||||||
Parser::Parser(Errors* errors, Scanner* scanner, CompilationUnits* compilationUnits)
|
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);
|
mGlobals = new DeclarationScope(compilationUnits->mScope, SLEVEL_STATIC);
|
||||||
mScope = mGlobals;
|
mScope = mGlobals;
|
||||||
|
@ -5295,6 +5295,9 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
|
||||||
|
|
||||||
if (variable)
|
if (variable)
|
||||||
{
|
{
|
||||||
|
if (storageFlags & DTF_CONSTEXPR)
|
||||||
|
ndec->mBase = ndec->mBase->ToConstType();
|
||||||
|
|
||||||
ndec->mFlags |= storageFlags;
|
ndec->mFlags |= storageFlags;
|
||||||
ndec->mFlags |= ndec->mBase->mFlags & (DTF_CONST | DTF_VOLATILE);
|
ndec->mFlags |= ndec->mBase->mFlags & (DTF_CONST | DTF_VOLATILE);
|
||||||
|
|
||||||
|
@ -7483,6 +7486,8 @@ int Parser::OverloadDistance(Declaration* fdec, Expression* pexp)
|
||||||
{
|
{
|
||||||
dist += 32;
|
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)
|
else if (ptype->mType == DT_TYPE_STRUCT && etype->mType == DT_TYPE_STRUCT)
|
||||||
{
|
{
|
||||||
int ncast = 0;
|
int ncast = 0;
|
||||||
|
@ -7870,7 +7875,7 @@ Expression * Parser::ResolveOverloadCall(Expression* exp, Expression* exp2)
|
||||||
fdec = fdec->mNext;
|
fdec = fdec->mNext;
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
else if (nbest > 1)
|
||||||
{
|
{
|
||||||
|
@ -7882,7 +7887,7 @@ Expression * Parser::ResolveOverloadCall(Expression* exp, Expression* exp2)
|
||||||
fdec = fdec->mNext;
|
fdec = fdec->mNext;
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
else
|
||||||
{
|
{
|
||||||
|
@ -11160,6 +11165,7 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
|
||||||
if (tmpld->mBase->mType == DT_TEMPLATE)
|
if (tmpld->mBase->mType == DT_TEMPLATE)
|
||||||
{
|
{
|
||||||
Parser* p = tmpld->mBase->mParser->Clone();
|
Parser* p = tmpld->mBase->mParser->Clone();
|
||||||
|
p->mParent = this;
|
||||||
|
|
||||||
p->mScanner->Replay(tmpld->mBase->mTokens);
|
p->mScanner->Replay(tmpld->mBase->mTokens);
|
||||||
|
|
||||||
|
@ -11450,6 +11456,7 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Parser* p = tmpld->mParser->Clone();
|
Parser* p = tmpld->mParser->Clone();
|
||||||
|
p->mParent = this;
|
||||||
|
|
||||||
p->mScanner->Replay(tmpld->mTokens);
|
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)
|
void Parser::Parse(void)
|
||||||
{
|
{
|
||||||
mLocalIndex = 0;
|
mLocalIndex = 0;
|
||||||
|
|
|
@ -11,6 +11,7 @@ public:
|
||||||
~Parser(void);
|
~Parser(void);
|
||||||
|
|
||||||
Parser* Clone(void);
|
Parser* Clone(void);
|
||||||
|
Parser * mParent;
|
||||||
|
|
||||||
DeclarationScope * mGlobals, * mScope, * mTemplateScope, * mCaptureScope;
|
DeclarationScope * mGlobals, * mScope, * mTemplateScope, * mCaptureScope;
|
||||||
int mLocalIndex;
|
int mLocalIndex;
|
||||||
|
@ -24,6 +25,8 @@ public:
|
||||||
uint64 mCompilerOptionStack[32];
|
uint64 mCompilerOptionStack[32];
|
||||||
int mCompilerOptionSP;
|
int mCompilerOptionSP;
|
||||||
|
|
||||||
|
Location FullLocation(const Location& loc);
|
||||||
|
|
||||||
void Parse(void);
|
void Parse(void);
|
||||||
protected:
|
protected:
|
||||||
bool ExpectToken(Token token);
|
bool ExpectToken(Token token);
|
||||||
|
|
Loading…
Reference in New Issue