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

View file

@ -2316,6 +2316,11 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
// structs and classes only get passed by pointer. // structs and classes only get passed by pointer.
type = NewPointer(type); 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. // TBD: disallow certain types? For now, let everything pass that isn't an array.
rets.Push(type); rets.Push(type);
t = static_cast<decltype(t)>(t->SiblingNext); t = static_cast<decltype(t)>(t->SiblingNext);