aboutsummaryrefslogtreecommitdiff
path: root/src/check_builtin.cpp
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2024-01-25 02:16:30 +0100
committerLaytan Laats <laytanlaats@hotmail.com>2024-06-06 19:46:01 +0200
commitb818a7713175d882a7f8b345cee59bd19b0d1d47 (patch)
tree8af78ef6d01411e3039932b96fc5067f12041a00 /src/check_builtin.cpp
parent9a95049393ea98ef6222bf217ab44dd127c3f960 (diff)
check if -define is actually used
Diffstat (limited to 'src/check_builtin.cpp')
-rw-r--r--src/check_builtin.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp
index b2afa3d0c..a74082fb2 100644
--- a/src/check_builtin.cpp
+++ b/src/check_builtin.cpp
@@ -1756,6 +1756,17 @@ gb_internal bool check_builtin_procedure_directive(CheckerContext *c, Operand *o
operand->mode = Addressing_Constant;
operand->value = exact_value_bool(is_defined);
+ // If the arg is a selector expression we don't add it, `-define` only allows identifiers.
+ if (arg->kind == Ast_Ident) {
+ Defineable defineable = {};
+ defineable.name = arg->Ident.token.string;
+ defineable.default_value = exact_value_bool(false);
+ defineable.pos = arg->Ident.token.pos;
+
+ MUTEX_GUARD(&c->info->defineables_mutex);
+ array_add(&c->info->defineables, defineable);
+ }
+
} else if (name == "config") {
if (ce->args.count != 2) {
error(call, "'#config' expects 2 argument, got %td", ce->args.count);
@@ -1777,7 +1788,7 @@ gb_internal bool check_builtin_procedure_directive(CheckerContext *c, Operand *o
}
String name = arg->Ident.token.string;
-
+
operand->type = def.type;
operand->mode = def.mode;
@@ -1794,7 +1805,7 @@ gb_internal bool check_builtin_procedure_directive(CheckerContext *c, Operand *o
}
}
- Defineable defineable = {};
+ Defineable defineable = {};
defineable.name = name;
defineable.default_value = def.value;
defineable.pos = arg->Ident.token.pos;