diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-06-11 00:09:58 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-06-11 00:09:58 -0400 |
| commit | 33371ab55c01d896b91df13eafe6e5c601400a07 (patch) | |
| tree | 879666e7729aaef2273e8c336b425909df3d2022 /src/parser.cpp | |
| parent | d504318f2e0f3054c772abbd34f938f2cefa6ccc (diff) | |
| parent | 34a22a85ca8d4371fe9b8f921cce858ab4351cca (diff) | |
| download | zig-33371ab55c01d896b91df13eafe6e5c601400a07.tar.gz zig-33371ab55c01d896b91df13eafe6e5c601400a07.zip | |
Merge remote-tracking branch 'origin/master' into copy-elision-3
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 179c241fd6..f35e54f6de 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -890,6 +890,11 @@ static AstNode *ast_parse_if_statement(ParseContext *pc) { body = ast_parse_assign_expr(pc); } + if (body == nullptr) { + Token *tok = eat_token(pc); + ast_error(pc, tok, "expected if body, found '%s'", token_name(tok->id)); + } + Token *err_payload = nullptr; AstNode *else_body = nullptr; if (eat_token_if(pc, TokenIdKeywordElse) != nullptr) { @@ -994,6 +999,11 @@ static AstNode *ast_parse_for_statement(ParseContext *pc) { body = ast_parse_assign_expr(pc); } + if (body == nullptr) { + Token *tok = eat_token(pc); + ast_error(pc, tok, "expected loop body, found '%s'", token_name(tok->id)); + } + AstNode *else_body = nullptr; if (eat_token_if(pc, TokenIdKeywordElse) != nullptr) { else_body = ast_expect(pc, ast_parse_statement); @@ -1023,6 +1033,11 @@ static AstNode *ast_parse_while_statement(ParseContext *pc) { body = ast_parse_assign_expr(pc); } + if (body == nullptr) { + Token *tok = eat_token(pc); + ast_error(pc, tok, "expected loop body, found '%s'", token_name(tok->id)); + } + Token *err_payload = nullptr; AstNode *else_body = nullptr; if (eat_token_if(pc, TokenIdKeywordElse) != nullptr) { |
