mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-21 14:06:37 +00:00
Add support for return; (#678)
This creates a ReturnExpression. A separate change should enforce that an implicit return of `()` is only allowed in functions that have an implicit return type of `()`, and I think the structure taken here should ease that.
This commit is contained in:
1 parent
b1993a6cd0
commit
6ae9cc3cf8
16 files changed
+114
-33
No files matched your search
@@ -60,6 +60,7 @@ struct If {
|
||||
struct Return {
|
||||
static constexpr StatementKind Kind = StatementKind::Return;
|
||||
const Expression* exp;
|
||||
bool is_omitted_exp;
|
||||
};
|
||||
|
||||
struct Sequence {
|
||||
@@ -120,7 +121,8 @@ struct Statement {
|
||||
static auto MakeIf(int line_num, const Expression* cond,
|
||||
const Statement* then_stmt, const Statement* else_stmt)
|
||||
-> const Statement*;
|
||||
static auto MakeReturn(int line_num, const Expression* e) -> const Statement*;
|
||||
static auto MakeReturn(int line_num, const Expression* exp,
|
||||
bool is_omitted_exp) -> const Statement*;
|
||||
static auto MakeSequence(int line_num, const Statement* s1,
|
||||
const Statement* s2) -> const Statement*;
|
||||
static auto MakeBlock(int line_num, const Statement* s) -> const Statement*;
|
||||
|
||||
Reference in new issue
Block a user