Forbade dynamic array as the return type of a function

Compiler ignored this case silently but it crashed during code generation
This commit is contained in:
alexey.lysiuk 2018-04-02 15:18:30 +03:00
parent 5df5e2abe7
commit ac7e5def32
1 changed files with 5 additions and 0 deletions

View File

@ -2316,6 +2316,11 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
// structs and classes only get passed by pointer.
type = NewPointer(type);
}
else if (type->isDynArray())
{
Error(f, "The return type of a function cannot be a dynamic array");
break;
}
// TBD: disallow certain types? For now, let everything pass that isn't an array.
rets.Push(type);
t = static_cast<decltype(t)>(t->SiblingNext);