aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-09-23 23:22:16 +0100
committergingerBill <bill@gingerbill.org>2021-09-23 23:22:16 +0100
commitea555c0ccd871a6641171f066688332b823781b7 (patch)
treee4f8e4fdd0edb122d118a6e2ebf70f06df9d0d97 /src/check_expr.cpp
parent6a86b3c82b06396d0edfcc9fcd9f359813e5d116 (diff)
Simplify directive parsing for expressions
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index d59c3fea9..08be7b7bc 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -5872,7 +5872,11 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr
operand->type = t_invalid;
add_type_and_value(c->info, proc, operand->mode, operand->type, operand->value);
} else {
- GB_PANIC("Unhandled #%.*s", LIT(name));
+ error(proc, "Unknown directive: #%.*s", LIT(name));
+ operand->expr = proc;
+ operand->type = t_invalid;
+ operand->mode = Addressing_Invalid;
+ return Expr_Expr;
}
if (inlining != ProcInlining_none) {
error(call, "Inlining operators are not allowed on built-in procedures");
@@ -6609,7 +6613,26 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
o->type = t_source_code_location;
o->mode = Addressing_Value;
} else {
- GB_PANIC("Unknown basic directive");
+ if (name == "location") {
+ init_core_source_code_location(c->checker);
+ error(node, "'#%.*s' must be used in a call expression", LIT(name));
+ o->type = t_source_code_location;
+ o->mode = Addressing_Value;
+ } else if (
+ name == "load" ||
+ name == "assert" ||
+ name == "defined" ||
+ name == "config"
+ ) {
+ error(node, "'#%.*s' must be used as a call", LIT(name));
+ o->type = t_invalid;
+ o->mode = Addressing_Invalid;
+ } else {
+ error(node, "Unknown directive: #%.*s", LIT(name));
+ o->type = t_invalid;
+ o->mode = Addressing_Invalid;
+ }
+
}
case_end;