mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- fixed incorrect extension of overridden function prototype
Prototype of overridden function with optional argument(s) missing could extend unrelated prototype of previously defined function when their arguments and return value(s) match https://forum.zdoom.org/viewtopic.php?t=71340
This commit is contained in:
parent
d7924d6e9d
commit
6bc82bdeff
2 changed files with 8 additions and 2 deletions
|
@ -706,13 +706,17 @@ int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction
|
|||
if (!(parentfunc->Variants[0].ArgFlags[a] & VARF_Optional)) return -1;
|
||||
}
|
||||
|
||||
// Todo: extend the prototype
|
||||
// Extend the prototype
|
||||
TArray<PType*> argumentTypes = proto->ArgumentTypes;
|
||||
|
||||
for (unsigned a = proto->ArgumentTypes.Size(); a < vproto->ArgumentTypes.Size(); a++)
|
||||
{
|
||||
proto->ArgumentTypes.Push(vproto->ArgumentTypes[a]);
|
||||
argumentTypes.Push(vproto->ArgumentTypes[a]);
|
||||
variant->ArgFlags.Push(parentfunc->Variants[0].ArgFlags[a]);
|
||||
variant->ArgNames.Push(NAME_None);
|
||||
}
|
||||
|
||||
variant->Proto = NewPrototype(proto->ReturnTypes, argumentTypes);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -2486,6 +2486,8 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
|||
{
|
||||
newfunc->ArgFlags.Push(sym->Variants[0].ArgFlags[i]);
|
||||
}
|
||||
|
||||
newfunc->Proto = sym->Variants[0].Proto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue