From 33223c7d9a80e821bccce25960f7e48ab425d975 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 24 Jun 2019 05:14:07 +0200 Subject: Fix errors from pedantic check --- amalgam.cflags | 1 + amalgam.config | 2 ++ amalgam.creator | 1 + amalgam.cxxflags | 1 + amalgam.files | 54 +++++++++++++++++++++++++++++++++++++++++++++ amalgam.includes | 4 ++++ include/bytecode/bytecode.h | 2 +- src/bytecode/bytecode.c | 1 + src/compiler.c | 2 +- src/parser.c | 9 ++++---- src/std/buffer.c | 2 +- tests/main.c | 4 +++- 12 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 amalgam.cflags create mode 100644 amalgam.config create mode 100644 amalgam.creator create mode 100644 amalgam.cxxflags create mode 100644 amalgam.files create mode 100644 amalgam.includes diff --git a/amalgam.cflags b/amalgam.cflags new file mode 100644 index 0000000..188be76 --- /dev/null +++ b/amalgam.cflags @@ -0,0 +1 @@ +-std=c89 diff --git a/amalgam.config b/amalgam.config new file mode 100644 index 0000000..e0284f4 --- /dev/null +++ b/amalgam.config @@ -0,0 +1,2 @@ +// Add predefined macros for your project here. For example: +// #define THE_ANSWER 42 diff --git a/amalgam.creator b/amalgam.creator new file mode 100644 index 0000000..e94cbbd --- /dev/null +++ b/amalgam.creator @@ -0,0 +1 @@ +[General] diff --git a/amalgam.cxxflags b/amalgam.cxxflags new file mode 100644 index 0000000..df98e0d --- /dev/null +++ b/amalgam.cxxflags @@ -0,0 +1 @@ +-std=c++14 diff --git a/amalgam.files b/amalgam.files new file mode 100644 index 0000000..1850f5c --- /dev/null +++ b/amalgam.files @@ -0,0 +1,54 @@ +build.sh +include/ast.h +include/binop_type.h +include/bytecode/bytecode.h +include/compiler.h +include/compiler_options.h +include/defs.h +include/parser.h +include/ssa/ssa.h +include/std/alloc.h +include/std/buffer.h +include/std/buffer_view.h +include/std/defs.h +include/std/file.h +include/std/hash.h +include/std/hash_map.h +include/std/log.h +include/std/mem.h +include/std/misc.h +include/std/scoped_allocator.h +include/std/thread.h +include/std/types.h +include/tokenizer.h +src/ast.c +src/bytecode/bytecode.c +src/compiler.c +src/parser.c +src/ssa/ssa.c +src/std/alloc.c +src/std/buffer.c +src/std/buffer_view.c +src/std/file.c +src/std/hash.c +src/std/hash_map.c +src/std/log.c +src/std/mem.c +src/std/scoped_allocator.c +src/std/thread.c +src/tokenizer.c +tests/b.amal +tests/b.amal.z +tests/bytecode.amal +tests/bytecode.amal.z +tests/errors/closure_no_lhs.amal +tests/errors/const_assign.amal +tests/errors/duplicate_declaration.amal +tests/errors/pub_in_closure.amal +tests/io.amal +tests/io.amal.z +tests/main.amal +tests/main.amal.z +tests/main.c +tests/sub/a.amal +tests/sub/a.amal.z diff --git a/amalgam.includes b/amalgam.includes new file mode 100644 index 0000000..5822a55 --- /dev/null +++ b/amalgam.includes @@ -0,0 +1,4 @@ +include +include/bytecode +include/ssa +include/std diff --git a/include/bytecode/bytecode.h b/include/bytecode/bytecode.h index 3a141f0..e5a70e9 100644 --- a/include/bytecode/bytecode.h +++ b/include/bytecode/bytecode.h @@ -9,7 +9,7 @@ #include typedef enum { - NOP, /* To allow hot-patching */ + NOP /* To allow hot-patching */ } BytecodeInstruction; diff --git a/src/bytecode/bytecode.c b/src/bytecode/bytecode.c index 8aae03e..6ceacf0 100644 --- a/src/bytecode/bytecode.c +++ b/src/bytecode/bytecode.c @@ -1,5 +1,6 @@ #include "../../include/bytecode/bytecode.h" #include "../../include/std/mem.h" +#include "../../include/std/log.h" #include "../../include/ssa/ssa.h" #include "../../include/parser.h" #include "../../include/compiler.h" diff --git a/src/compiler.c b/src/compiler.c index 2b59a93..9f003c8 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -67,7 +67,7 @@ void amal_compiler_options_init(amal_compiler_options *self) { int amal_compiler_init(amal_compiler *self, const amal_compiler_options *options) { int i; - self->usable_thread_count = options->num_threads; + self->usable_thread_count = options ? options->num_threads : 0; if(self->usable_thread_count == 0) { self->usable_thread_count = amal_get_usable_thread_count(); if(self->usable_thread_count == 0) { diff --git a/src/parser.c b/src/parser.c index c0d2c6d..68d0648 100644 --- a/src/parser.c +++ b/src/parser.c @@ -296,7 +296,6 @@ static void parser_parse_function_args(Parser *self, FunctionCall *func_call) { for(;;) { Ast *arg_expr; bool is_end_token; - arg_expr = NULL; throw_if_error(tokenizer_consume_if(&self->tokenizer, TOK_CLOSING_PAREN, &is_end_token)); if(is_end_token) @@ -638,7 +637,11 @@ Ast* parser_parse_body(Parser *self) { lhs_expr = parser_parse_declaration_lhs(self); if(lhs_expr) { + FunctionDecl *func_decl; + StructDecl *struct_decl; + Import *import; bool match; + throw_if_error(ast_create(self->allocator, lhs_expr, AST_LHS, &result)); if(lhs_expr->is_extern) { throw_if_error(tokenizer_accept(&self->tokenizer, TOK_SEMICOLON)); @@ -651,10 +654,6 @@ Ast* parser_parse_body(Parser *self) { throw_if_error(tokenizer_accept(&self->tokenizer, TOK_EQUALS)); - FunctionDecl *func_decl; - StructDecl *struct_decl; - Import *import; - func_decl = parser_parse_closure(self); if(func_decl) { throw_if_error(ast_create(self->allocator, func_decl, AST_FUNCTION_DECL, &lhs_expr->rhs_expr)); diff --git a/src/std/buffer.c b/src/std/buffer.c index ddf7d39..3676cee 100644 --- a/src/std/buffer.c +++ b/src/std/buffer.c @@ -12,7 +12,7 @@ int buffer_init(Buffer *self, struct ScopedAllocator *allocator) { if(allocator) { return scoped_allocator_add_mem(allocator, &self->allocator_index); } else { - self->allocator_index = ~0ULL; + self->allocator_index = ~(usize)0; return 0; } } diff --git a/tests/main.c b/tests/main.c index c4c567d..520d8b4 100644 --- a/tests/main.c +++ b/tests/main.c @@ -3,6 +3,7 @@ #include "../include/compiler.h" #include "../include/std/hash_map.h" #include "../include/std/hash.h" +#include "../include/std/log.h" #include #include #include @@ -181,6 +182,7 @@ static void test_load(const char *filepath) { static void test_load_error(const char *filepath, const char *expected_error) { amal_compiler compiler; amal_compiler_options options; + ErrorExpectedData expected_data; int result; int num_threads; @@ -197,7 +199,7 @@ static void test_load_error(const char *filepath, const char *expected_error) { options.num_threads = num_threads; ++num_tests_run; options.error_callback = error_callback_assert; - ErrorExpectedData expected_data; + expected_data.filepath = get_full_path(filepath); expected_data.expected_error = join_str(expected_data.filepath, expected_error, ':'); expected_data.got_expected_error = bool_false; -- cgit v1.2.3