From fed14a31ca554b54c4f2eebefd09aeaeda782aba Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sun, 17 Feb 2019 12:33:32 -0800 Subject: Disallow functions returning array or function --- decl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/decl.c b/decl.c index 6fb74fc..f9640fc 100644 --- a/decl.c +++ b/decl.c @@ -544,6 +544,12 @@ declarator(struct scope *s, struct type *base, char **name, bool allowabstract) t = listelement(l, struct type, link); t->base = base; switch (t->kind) { + case TYPEFUNC: + if (base->kind == TYPEFUNC) + error(&tok.loc, "function declarator specifies function return type"); + if (base->kind == TYPEARRAY) + error(&tok.loc, "function declarator specifies array return type"); + break; case TYPEARRAY: t->align = base->align; t->size = base->size * t->array.length; // XXX: overflow? -- cgit v1.2.3