From c4585f9bbd2ecb0064c44bdcab890f4b5c115f23 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Thu, 29 Apr 2021 17:18:50 +0200 Subject: [PATCH] Remove suppressed warning. --- CMakeLists.txt | 2 +- src/compiler/bigint.c | 4 ++-- src/compiler/number.c | 4 ++-- src/compiler/target.c | 2 +- src/compiler/types.c | 18 +++++++++--------- src/compiler_tests/tests.c | 2 +- src/utils/file_utils.c | 8 ++++---- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b0ae45a4..71e7013bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,7 +143,7 @@ add_executable(c3c src/compiler/llvm_codegen_c_abi_riscv.c src/compiler/llvm_codegen_c_abi_wasm.c) -target_compile_options(c3c PRIVATE -Wsign-compare -Wno-unknown-warning-option -Wno-unused-result -Wno-maybe-uninitialized -Wimplicit-int -Werror -Wall -Wno-unknown-pragmas -Wextra -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter) +target_compile_options(c3c PRIVATE -Wsign-compare -Wno-unknown-warning-option -Wno-maybe-uninitialized -Wimplicit-int -Werror -Wall -Wno-unknown-pragmas -Wextra -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter) target_include_directories(c3c PRIVATE "${CMAKE_SOURCE_DIR}/src/") diff --git a/src/compiler/bigint.c b/src/compiler/bigint.c index ea7b4ef50..e9ccbf9c6 100644 --- a/src/compiler/bigint.c +++ b/src/compiler/bigint.c @@ -1898,11 +1898,11 @@ const char *bigint_to_error_string(const BigInt *bigint, uint64_t base) char *res = NULL; if (bigint->is_negative) { - asprintf(&res, "-%" PRIu64, bigint->digit); + (void)asprintf(&res, "-%" PRIu64, bigint->digit); } else { - asprintf(&res, "%" PRIu64, bigint->digit); + (void)asprintf(&res, "%" PRIu64, bigint->digit); } return res; } diff --git a/src/compiler/number.c b/src/compiler/number.c index 1a2db1369..0f7187970 100644 --- a/src/compiler/number.c +++ b/src/compiler/number.c @@ -253,10 +253,10 @@ const char *expr_const_to_error_string(const ExprConst *expr) case TYPE_F32: case TYPE_F64: case TYPE_FXX: - asprintf(&buff, "%Lf", expr->f); + (void)asprintf(&buff, "%Lf", expr->f); return buff; case TYPE_STRLIT: - asprintf(&buff, "\"%*.s\"", expr->string.len, expr->string.chars); + (void)asprintf(&buff, "\"%*.s\"", expr->string.len, expr->string.chars); return buff; default: UNREACHABLE diff --git a/src/compiler/target.c b/src/compiler/target.c index a0e664091..2dd725041 100644 --- a/src/compiler/target.c +++ b/src/compiler/target.c @@ -176,7 +176,7 @@ void llvm_dump(void) LLVMTargetRef target; char *error; char *triplet = NULL; - asprintf(&triplet, "%s-unknown-%s-unknown", archs[i], os[j]); + (void)asprintf(&triplet, "%s-unknown-%s-unknown", archs[i], os[j]); if (LLVMGetTargetFromTriple(triplet, &target, &error)) continue; LLVMTargetMachineRef machine = NULL; if (!(machine = LLVMCreateTargetMachine(target, triplet, "", "", 0, LLVMRelocDefault, LLVMCodeModelDefault))) { diff --git a/src/compiler/types.c b/src/compiler/types.c index b1a05ff59..282ed2baa 100644 --- a/src/compiler/types.c +++ b/src/compiler/types.c @@ -95,10 +95,10 @@ const char *type_quoted_error_string(Type *type) char *buffer = NULL; if (type->canonical != type) { - asprintf(&buffer, "'%s' (%s)", type_to_error_string(type), type_to_error_string(type->canonical)); + (void)asprintf(&buffer, "'%s' (%s)", type_to_error_string(type), type_to_error_string(type->canonical)); return buffer; } - asprintf(&buffer, "'%s'", type_to_error_string(type)); + (void)asprintf(&buffer, "'%s'", type_to_error_string(type)); return buffer; } const char *type_to_error_string(Type *type) @@ -123,7 +123,7 @@ const char *type_to_error_string(Type *type) return type->name; case TYPE_FUNC: { - asprintf(&buffer, type->func.signature->failable ? "func %s!(" : "func %s(", + (void)asprintf(&buffer, type->func.signature->failable ? "func %s!(" : "func %s(", type_to_error_string(type->func.signature->rtype->type)); VECEACH(type->func.signature->params, i) { @@ -148,7 +148,7 @@ const char *type_to_error_string(Type *type) UNREACHABLE } case TYPE_VECTOR: - asprintf(&buffer, "%s[<%llu>]", type_to_error_string(type->array.base), (unsigned long long)type->array.len); + (void)asprintf(&buffer, "%s[<%llu>]", type_to_error_string(type->array.base), (unsigned long long)type->array.len); return buffer; case TYPE_MEMBER: return "member"; @@ -161,21 +161,21 @@ const char *type_to_error_string(Type *type) { return type_to_error_string(type->pointer); } - asprintf(&buffer, "%s*", type_to_error_string(type->pointer)); + (void)asprintf(&buffer, "%s*", type_to_error_string(type->pointer)); return buffer; case TYPE_STRLIT: return "compile time string"; case TYPE_ARRAY: - asprintf(&buffer, "%s[%llu]", type_to_error_string(type->array.base), (unsigned long long)type->array.len); + (void)asprintf(&buffer, "%s[%llu]", type_to_error_string(type->array.base), (unsigned long long)type->array.len); return buffer; case TYPE_VARARRAY: - asprintf(&buffer, "%s[*]", type_to_error_string(type->array.base)); + (void)asprintf(&buffer, "%s[*]", type_to_error_string(type->array.base)); return buffer; case TYPE_INFERRED_ARRAY: - asprintf(&buffer, "%s[?]", type_to_error_string(type->array.base)); + (void)asprintf(&buffer, "%s[?]", type_to_error_string(type->array.base)); return buffer; case TYPE_SUBARRAY: - asprintf(&buffer, "%s[]", type_to_error_string(type->array.base)); + (void)asprintf(&buffer, "%s[]", type_to_error_string(type->array.base)); return buffer; case TYPE_ERR_UNION: return "error"; diff --git a/src/compiler_tests/tests.c b/src/compiler_tests/tests.c index 5c1e0b57a..031909885 100644 --- a/src/compiler_tests/tests.c +++ b/src/compiler_tests/tests.c @@ -117,7 +117,7 @@ void test_compiler(void) { printf("Running %s...\n", files[i]); char *res = NULL; - asprintf(&res, "tests/%s", files[i]); + (void)asprintf(&res, "tests/%s", files[i]); single_file[0] = res; BuildTarget target = { .type = TARGET_TYPE_EXECUTABLE, .sources = single_file, .name = "a.out" }; compile_files(&target); diff --git a/src/utils/file_utils.c b/src/utils/file_utils.c index c1fe683b2..276c3e6bf 100644 --- a/src/utils/file_utils.c +++ b/src/utils/file_utils.c @@ -99,24 +99,24 @@ const char* find_lib_dir(void) struct stat info; char *lib_path = NULL; - asprintf(&lib_path, "%s../lib/std/", path); + (void)asprintf(&lib_path, "%s../lib/std/", path); DEBUG_LOG("Checking %s", lib_path); int err = stat(lib_path, &info); // Found it at ../lib/std if (!err && S_ISDIR(info.st_mode)) { - asprintf(&lib_path, "%s../lib/", path); + (void)asprintf(&lib_path, "%s../lib/", path); return lib_path; } - asprintf(&lib_path, "%slib/std/", path); + (void)asprintf(&lib_path, "%slib/std/", path); err = stat(lib_path, &info); // Found it at ./lib/std if (!err && S_ISDIR(info.st_mode)) { - asprintf(&lib_path, "%slib/", path); + (void)asprintf(&lib_path, "%slib/", path); return lib_path; }