mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
Fixed: check protected fields against analog of OwningClass in functions, as opposed to the type that the field was accessed from.
This commit is contained in:
parent
3eafc13b08
commit
1832531726
1 changed files with 27 additions and 3 deletions
|
@ -6084,10 +6084,34 @@ FxExpression *FxIdentifier::ResolveMember(FCompileContext &ctx, PStruct *classct
|
|||
}
|
||||
PClass* cls_ctx = dyn_cast<PClass>(classctx);
|
||||
PClass* cls_target = dyn_cast<PClass>(objtype);
|
||||
if ((vsym->Flags & VARF_Protected) && (!cls_ctx || !cls_target || !cls_ctx->IsDescendantOf(cls_target)))
|
||||
// [ZZ] neither PSymbol, PField or PSymbolTable have the necessary information. so we need to do the more complex check here.
|
||||
if (vsym->Flags & VARF_Protected)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Protected member %s not accessible", vsym->SymbolName.GetChars());
|
||||
return nullptr;
|
||||
// early break.
|
||||
if (!cls_ctx || !cls_target)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Protected member %s not accessible", vsym->SymbolName.GetChars());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// find the class that declared this field.
|
||||
PClass* p = cls_target;
|
||||
while (p)
|
||||
{
|
||||
if (&p->Symbols == symtbl)
|
||||
{
|
||||
cls_target = p;
|
||||
break;
|
||||
}
|
||||
|
||||
p = p->ParentClass;
|
||||
}
|
||||
|
||||
if (!cls_ctx->IsDescendantOf(cls_target))
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Protected member %s not accessible", vsym->SymbolName.GetChars());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
auto x = isclass ? new FxClassMember(object, vsym, ScriptPosition) : new FxStructMember(object, vsym, ScriptPosition);
|
||||
|
|
Loading…
Reference in a new issue