mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +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,12 +6084,36 @@ FxExpression *FxIdentifier::ResolveMember(FCompileContext &ctx, PStruct *classct
|
||||||
}
|
}
|
||||||
PClass* cls_ctx = dyn_cast<PClass>(classctx);
|
PClass* cls_ctx = dyn_cast<PClass>(classctx);
|
||||||
PClass* cls_target = dyn_cast<PClass>(objtype);
|
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)
|
||||||
|
{
|
||||||
|
// early break.
|
||||||
|
if (!cls_ctx || !cls_target)
|
||||||
{
|
{
|
||||||
ScriptPosition.Message(MSG_ERROR, "Protected member %s not accessible", vsym->SymbolName.GetChars());
|
ScriptPosition.Message(MSG_ERROR, "Protected member %s not accessible", vsym->SymbolName.GetChars());
|
||||||
return nullptr;
|
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);
|
auto x = isclass ? new FxClassMember(object, vsym, ScriptPosition) : new FxStructMember(object, vsym, ScriptPosition);
|
||||||
object = nullptr;
|
object = nullptr;
|
||||||
return x->Resolve(ctx);
|
return x->Resolve(ctx);
|
||||||
|
|
Loading…
Reference in a new issue