Fix compare pointer to rvalue refs
This commit is contained in:
parent
f7b00eff95
commit
a2ca0de809
|
@ -2323,6 +2323,16 @@ bool Declaration::IsSameMutable(const Declaration* dec) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Declaration::IsConstRefSame(const Declaration* dec) const
|
||||
{
|
||||
if (IsReference())
|
||||
return mBase->IsConstRefSame(dec);
|
||||
else if (dec->IsReference())
|
||||
return IsConstRefSame(dec->mBase);
|
||||
else
|
||||
return IsConstSame(dec);
|
||||
}
|
||||
|
||||
bool Declaration::IsConstSame(const Declaration* dec) const
|
||||
{
|
||||
if (this == dec)
|
||||
|
|
|
@ -306,6 +306,7 @@ public:
|
|||
bool IsSame(const Declaration* dec) const;
|
||||
bool IsDerivedFrom(const Declaration* dec) const;
|
||||
bool IsSubType(const Declaration* dec) const;
|
||||
bool IsConstRefSame(const Declaration* dec) const;
|
||||
bool IsConstSame(const Declaration* dec) const;
|
||||
bool IsSameValue(const Declaration* dec) const;
|
||||
bool IsSameParams(const Declaration* dec) const;
|
||||
|
|
|
@ -41,6 +41,7 @@ enum ErrorID
|
|||
EWARN_FLOAT_TO_INT,
|
||||
EWARN_UNDEFINED_POINTER_ARITHMETIC,
|
||||
EWARN_INVALID_VALUE_RANGE,
|
||||
EWARN_DEFAULT_COPY_DEPRECATED,
|
||||
|
||||
EERR_GENERIC = 3000,
|
||||
EERR_FILE_NOT_FOUND,
|
||||
|
@ -111,6 +112,7 @@ enum ErrorID
|
|||
|
||||
EERR_INVALID_PREPROCESSOR,
|
||||
EERR_INVALID_CLASS_INITIALIZER,
|
||||
EERR_CALL_OF_DELETED_FUNCTION,
|
||||
|
||||
EFATAL_GENERIC = 4000,
|
||||
EFATAL_OUT_OF_MEMORY,
|
||||
|
|
|
@ -1818,7 +1818,10 @@ void InterCodeGenerator::CopyStruct(InterCodeProcedure* proc, Expression* exp, I
|
|||
if (!(pdec->mFlags & DTF_FPARAM_UNUSED))
|
||||
block->Append(wins);
|
||||
|
||||
TranslateExpression(ftype, proc, block, fexp, destack, gotos, BranchTarget(), BranchTarget(), &nmapper);
|
||||
if (!fexp)
|
||||
mErrors->Error(exp->mLocation, EERR_CALL_OF_DELETED_FUNCTION, "Call of deleted copy constructor");
|
||||
else
|
||||
TranslateExpression(ftype, proc, block, fexp, destack, gotos, BranchTarget(), BranchTarget(), &nmapper);
|
||||
|
||||
InterInstruction* jins = new InterInstruction(MapLocation(exp, inlineMapper), IC_JUMP);
|
||||
block->Append(jins);
|
||||
|
@ -3282,7 +3285,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
;
|
||||
else if ((mCompilerOptions & COPT_CPLUSPLUS) && (vl.mType->mBase->IsSubType(vr.mType->mBase) || vr.mType->mBase->IsSubType(vl.mType->mBase)))
|
||||
;
|
||||
else if (!vl.mType->mBase->IsConstSame(vr.mType->mBase))
|
||||
else if (!vl.mType->mBase->IsConstRefSame(vr.mType->mBase))
|
||||
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Incompatible pointer types", vl.mType->mBase->MangleIdent(), vr.mType->mBase->MangleIdent());
|
||||
}
|
||||
else
|
||||
|
|
|
@ -2345,6 +2345,7 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
|
|||
bool inlineConstructor = true;
|
||||
bool inlineCopy = true;
|
||||
bool inlineMove = true;
|
||||
bool explicitDestructor = false;
|
||||
|
||||
|
||||
const Ident* dtorident = pthis->mBase->mIdent->PreMangle("~");;
|
||||
|
@ -2374,7 +2375,10 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
|
|||
|
||||
Declaration* ddec = pthis->mBase->mScope->Lookup(dtorident, SLEVEL_SCOPE);
|
||||
if (ddec)
|
||||
{
|
||||
pthis->mBase->mDestructor = ddec;
|
||||
explicitDestructor = true;
|
||||
}
|
||||
|
||||
Declaration* adec = pthis->mBase->mScope->Lookup(Ident::Unique("operator="), SLEVEL_SCOPE);
|
||||
while (adec)
|
||||
|
@ -2423,6 +2427,12 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
|
|||
if (pthis->mBase->mVTable)
|
||||
simpleConstructor = false;
|
||||
|
||||
if (explicitDestructor)
|
||||
{
|
||||
simpleCopy = false;
|
||||
simpleAssignment = false;
|
||||
}
|
||||
|
||||
Declaration* dec = pthis->mBase->mParams;
|
||||
while (dec)
|
||||
{
|
||||
|
@ -2589,6 +2599,9 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
|
|||
|
||||
cdec->mVarIndex = -1;
|
||||
|
||||
if (explicitDestructor)
|
||||
mErrors->Error(pthis->mBase->mLocation, EWARN_DEFAULT_COPY_DEPRECATED, "Default copy constructor deprecated due to explicit destructor");
|
||||
|
||||
cdec->mValue = new Expression(mScanner->mLocation, EX_VOID);
|
||||
|
||||
// Now add all the copying
|
||||
|
@ -2758,6 +2771,9 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
|
|||
|
||||
cdec->mVarIndex = -1;
|
||||
|
||||
if (explicitDestructor)
|
||||
mErrors->Error(pthis->mBase->mLocation, EWARN_DEFAULT_COPY_DEPRECATED, "Default copy constructor deprecated due to explicit destructor");
|
||||
|
||||
Expression* pthisexp = new Expression(pthis->mLocation, EX_VARIABLE);
|
||||
pthisexp->mDecType = pthis;
|
||||
pthisexp->mDecValue = cdec->mBase->mParams;
|
||||
|
@ -10168,6 +10184,8 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
|
|||
packd->mBase = new Declaration(dec->mLocation, DT_PACK_TYPE);
|
||||
if (ppdec)
|
||||
ppdec->mNext = packd;
|
||||
else if (tdec->mParams && !tdec->mParams->mNext && tdec->mParams->mType == DT_TYPE_TEMPLATE)
|
||||
;
|
||||
else
|
||||
tdec->mParams = packd;
|
||||
|
||||
|
|
Loading…
Reference in New Issue