summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/parse.c b/parse.c
index 4fe1f26..cf67805 100644
--- a/parse.c
+++ b/parse.c
@@ -3,6 +3,10 @@ static bool parse_stmt(Parser *p, Statement *s);
#define PARSE_DECL_ALLOW_CONST_WITH_NO_EXPR 0x01
static bool parse_decl(Parser *p, Declaration *d, DeclEndKind ends_with, uint16_t flags);
+static bool is_decl(Tokenizer *t);
+static inline bool ends_decl(Token *t, DeclEndKind ends_with);
+
+
static const char *expr_kind_to_str(ExprKind k) {
switch (k) {
case EXPR_LITERAL_FLOAT: return "float literal";
@@ -636,6 +640,8 @@ static bool parser_is_definitely_type(Parser *p, Token **end) {
if (paren_level == 0) {
t->token++;
if (token_is_kw(t->token, KW_LBRACE)) goto end; /* void fn expr */
+ if (is_decl(t)) /* has return declaration */
+ goto end;
Type return_type;
bool prev = t->token->where.ctx->enabled;
t->token->where.ctx->enabled = false;
@@ -744,9 +750,6 @@ static bool parse_block(Parser *p, Block *b) {
return ret;
}
-static bool is_decl(Tokenizer *t);
-static inline bool ends_decl(Token *t, DeclEndKind ends_with);
-
static bool parse_decl_list(Parser *p, Declaration **decls, DeclEndKind decl_end) {
Tokenizer *t = p->tokr;
bool ret = true;