aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-08 17:17:15 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-08 17:17:15 -0400
commitaeed1992e94c5ab6a5104a06a921101fbe8f40ed (patch)
tree8ba6dc531acefa0eedd330224f16f750496e8dbe /compile.c
parentcf9d5b1619b9e5e886d2754f167046ff77d36abf (diff)
Fix nearly every GCC warning and add __attribute__((pure/const)) where
appropriate
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/compile.c b/compile.c
index 74ba3228..b2c59bb3 100644
--- a/compile.c
+++ b/compile.c
@@ -1401,6 +1401,7 @@ CORD compile_arguments(env_t *env, ast_t *call_ast, arg_t *spec_args, arg_ast_t
CORD code = CORD_EMPTY;
env_t *default_scope = global_scope(env);
for (arg_t *spec_arg = spec_args; spec_arg; spec_arg = spec_arg->next) {
+ int64_t i = 1;
// Find keyword:
if (spec_arg->name) {
for (arg_ast_t *call_arg = call_args; call_arg; call_arg = call_arg->next) {
@@ -1428,7 +1429,6 @@ CORD compile_arguments(env_t *env, ast_t *call_ast, arg_t *spec_args, arg_ast_t
}
}
// Find positional:
- int64_t i = 1;
for (arg_ast_t *call_arg = call_args; call_arg; call_arg = call_arg->next) {
if (call_arg->name) continue;
const char *pseudoname = heap_strf("%ld", i++);
@@ -1555,6 +1555,7 @@ static CORD compile_string_literal(CORD literal)
{
CORD code = "\"";
CORD_pos i;
+#pragma GCC diagnostic ignored "-Wsign-conversion"
CORD_FOR(i, literal) {
char c = CORD_pos_fetch(i);
switch (c) {
@@ -2939,10 +2940,8 @@ CORD compile(env_t *env, ast_t *ast)
case Declare: case Assign: case UpdateAssign: case For: case While: case StructDef: case LangDef:
case EnumDef: case FunctionDef: case Skip: case Stop: case Pass: case Return: case DocTest: case PrintStatement:
code_err(ast, "This is not a valid expression");
- case Unknown: code_err(ast, "Unknown AST");
+ default: case Unknown: code_err(ast, "Unknown AST");
}
- code_err(ast, "Unknown AST: %W", ast);
- return CORD_EMPTY;
}
void compile_namespace(env_t *env, const char *ns_name, ast_t *block)