Visibility in base classes
This commit is contained in:
parent
3d6b60c9f4
commit
fa9aa9c2bb
|
@ -99,6 +99,15 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt)
|
||||||
if ((mCompilerOptions & COPT_CPLUSPLUS) && mScanner->mToken == TK_COLON)
|
if ((mCompilerOptions & COPT_CPLUSPLUS) && mScanner->mToken == TK_COLON)
|
||||||
{
|
{
|
||||||
mScanner->NextToken();
|
mScanner->NextToken();
|
||||||
|
uint64 pflags = flags;
|
||||||
|
|
||||||
|
if (ConsumeTokenIf(TK_PUBLIC))
|
||||||
|
pflags &= ~(DTF_PRIVATE | DTF_PROTECTED);
|
||||||
|
else if (ConsumeTokenIf(TK_PROTECTED))
|
||||||
|
pflags = (pflags & ~DTF_PRIVATE) | DTF_PROTECTED;
|
||||||
|
else if (ConsumeTokenIf(TK_PRIVATE))
|
||||||
|
pflags |= DTF_PRIVATE | DTF_PROTECTED;
|
||||||
|
|
||||||
Declaration* pdec = ParseQualIdent();
|
Declaration* pdec = ParseQualIdent();
|
||||||
if (pdec)
|
if (pdec)
|
||||||
{
|
{
|
||||||
|
@ -106,6 +115,7 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt)
|
||||||
{
|
{
|
||||||
Declaration* bcdec = new Declaration(mScanner->mLocation, DT_BASECLASS);
|
Declaration* bcdec = new Declaration(mScanner->mLocation, DT_BASECLASS);
|
||||||
bcdec->mBase = pdec;
|
bcdec->mBase = pdec;
|
||||||
|
bcdec->mFlags = pflags;
|
||||||
|
|
||||||
dec->mSize = pdec->mSize;
|
dec->mSize = pdec->mSize;
|
||||||
|
|
||||||
|
@ -496,7 +506,7 @@ Declaration* Parser::ParseBaseTypeDeclaration(uint64 flags)
|
||||||
dec = ParseStructDeclaration(flags, DT_TYPE_STRUCT);
|
dec = ParseStructDeclaration(flags, DT_TYPE_STRUCT);
|
||||||
break;
|
break;
|
||||||
case TK_CLASS:
|
case TK_CLASS:
|
||||||
dec = ParseStructDeclaration(flags | DTF_PRIVATE, DT_TYPE_STRUCT);
|
dec = ParseStructDeclaration(flags | DTF_PRIVATE | DTF_PROTECTED, DT_TYPE_STRUCT);
|
||||||
break;
|
break;
|
||||||
case TK_UNION:
|
case TK_UNION:
|
||||||
dec = ParseStructDeclaration(flags, DT_TYPE_UNION);
|
dec = ParseStructDeclaration(flags, DT_TYPE_UNION);
|
||||||
|
@ -3969,10 +3979,11 @@ Expression* Parser::ParseSimpleExpression(bool lhs)
|
||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
Declaration* Parser::MemberLookup(Declaration* dtype, const Ident* ident, int & offset)
|
Declaration* Parser::MemberLookup(Declaration* dtype, const Ident* ident, int & offset, uint64& flags)
|
||||||
{
|
{
|
||||||
Declaration* mdec = dtype->mScope->Lookup(ident);
|
Declaration* mdec = dtype->mScope->Lookup(ident);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
flags = 0;
|
||||||
|
|
||||||
if (!mdec)
|
if (!mdec)
|
||||||
{
|
{
|
||||||
|
@ -3981,7 +3992,9 @@ Declaration* Parser::MemberLookup(Declaration* dtype, const Ident* ident, int &
|
||||||
while (bcdec)
|
while (bcdec)
|
||||||
{
|
{
|
||||||
int noffset;
|
int noffset;
|
||||||
Declaration* ndec = MemberLookup(bcdec->mBase, ident, noffset);
|
uint64 nflags;
|
||||||
|
|
||||||
|
Declaration* ndec = MemberLookup(bcdec->mBase, ident, noffset, nflags);
|
||||||
if (ndec)
|
if (ndec)
|
||||||
{
|
{
|
||||||
if (mdec)
|
if (mdec)
|
||||||
|
@ -3990,11 +4003,14 @@ Declaration* Parser::MemberLookup(Declaration* dtype, const Ident* ident, int &
|
||||||
{
|
{
|
||||||
mdec = ndec;
|
mdec = ndec;
|
||||||
offset = noffset + bcdec->mOffset;
|
offset = noffset + bcdec->mOffset;
|
||||||
|
flags = nflags | bcdec->mFlags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bcdec = bcdec->mNext;
|
bcdec = bcdec->mNext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
flags = mdec->mFlags;
|
||||||
|
|
||||||
return mdec;
|
return mdec;
|
||||||
}
|
}
|
||||||
|
@ -4014,11 +4030,12 @@ Expression* Parser::ParseQualify(Expression* exp)
|
||||||
if (mScanner->mToken == TK_IDENT)
|
if (mScanner->mToken == TK_IDENT)
|
||||||
{
|
{
|
||||||
int moffset;
|
int moffset;
|
||||||
Declaration* mdec = MemberLookup(dtype, mScanner->mTokenIdent, moffset);
|
uint64 mflags;
|
||||||
|
Declaration* mdec = MemberLookup(dtype, mScanner->mTokenIdent, moffset, mflags);
|
||||||
|
|
||||||
if (mdec)
|
if (mdec)
|
||||||
{
|
{
|
||||||
if (mdec->mFlags & DTF_PROTECTED)
|
if (mflags & DTF_PROTECTED)
|
||||||
{
|
{
|
||||||
if (!mThisPointer || mThisPointer->mBase->IsConstSame(dtype))
|
if (!mThisPointer || mThisPointer->mBase->IsConstSame(dtype))
|
||||||
mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Struct member identifier not visible", mScanner->mTokenIdent);
|
mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Struct member identifier not visible", mScanner->mTokenIdent);
|
||||||
|
|
|
@ -82,7 +82,7 @@ protected:
|
||||||
Expression* ParseStatement(void);
|
Expression* ParseStatement(void);
|
||||||
Expression* ParseSwitchStatement(void);
|
Expression* ParseSwitchStatement(void);
|
||||||
|
|
||||||
Declaration* MemberLookup(Declaration* dtype, const Ident * ident, int& offset);
|
Declaration* MemberLookup(Declaration* dtype, const Ident * ident, int& offset, uint64 & flags);
|
||||||
|
|
||||||
Expression* ParseQualify(Expression * exp);
|
Expression* ParseQualify(Expression * exp);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue