mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01: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:
@@ -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