aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-02-17 12:33:32 -0800
committerMichael Forney <mforney@mforney.org>2019-02-17 12:33:32 -0800
commitfed14a31ca554b54c4f2eebefd09aeaeda782aba (patch)
tree9e4d1e1058f124535bc0f7cf5dc5f5c58b6b6dc0
parent8f75d2840daf36870bee142709530586d138ce63 (diff)
downloadcproc-fed14a31ca554b54c4f2eebefd09aeaeda782aba.tar.xz
Disallow functions returning array or function
-rw-r--r--decl.c6
1 files changed, 6 insertions, 0 deletions
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?