mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix is_diverging_stmt for invalid statements
This commit is contained in:
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
bool is_divigering_stmt(Ast *stmt) {
|
bool is_diverging_stmt(Ast *stmt) {
|
||||||
if (stmt->kind != Ast_ExprStmt) {
|
if (stmt->kind != Ast_ExprStmt) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ bool is_divigering_stmt(Ast *stmt) {
|
|||||||
}
|
}
|
||||||
Type *t = type_of_expr(expr->CallExpr.proc);
|
Type *t = type_of_expr(expr->CallExpr.proc);
|
||||||
t = base_type(t);
|
t = base_type(t);
|
||||||
return t->kind == Type_Proc && t->Proc.diverging;
|
return t != nullptr && t->kind == Type_Proc && t->Proc.diverging;
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_stmt_list(CheckerContext *ctx, Slice<Ast *> const &stmts, u32 flags) {
|
void check_stmt_list(CheckerContext *ctx, Slice<Ast *> const &stmts, u32 flags) {
|
||||||
@@ -69,7 +69,7 @@ void check_stmt_list(CheckerContext *ctx, Slice<Ast *> const &stmts, u32 flags)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Ast_ExprStmt:
|
case Ast_ExprStmt:
|
||||||
if (is_divigering_stmt(n)) {
|
if (is_diverging_stmt(n)) {
|
||||||
error(n, "Statements after a diverging procedure call are never executed");
|
error(n, "Statements after a diverging procedure call are never executed");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -86,7 +86,7 @@ bool check_is_terminating_list(Slice<Ast *> const &stmts, String const &label) {
|
|||||||
// Okay
|
// Okay
|
||||||
} else if (stmt->kind == Ast_ValueDecl && !stmt->ValueDecl.is_mutable) {
|
} else if (stmt->kind == Ast_ValueDecl && !stmt->ValueDecl.is_mutable) {
|
||||||
// Okay
|
// Okay
|
||||||
} else if (is_divigering_stmt(stmt)) {
|
} else if (is_diverging_stmt(stmt)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return check_is_terminating(stmt, label);
|
return check_is_terminating(stmt, label);
|
||||||
|
|||||||
Reference in New Issue
Block a user