chore: Added compile warnings

Enabled compilation warnings and solved compilation problems.

TODO: Is it correct to have the warnings `hard-coded` on the CMakeFiles?
This commit is contained in:
erick-alcachofa 2025-05-10 21:07:49 -06:00
parent 85a34bdd65
commit 85dd8bc10f
Signed by: me
GPG Key ID: 6FA5F8643444BAFA
6 changed files with 57 additions and 5 deletions

15
.clangd
View File

@ -1,4 +1,17 @@
CompileFlags:
Add: [ -std=c++23 ]
Add:
- -pedantic
- -Wall
- -Wextra
- -Wold-style-cast
- -Wsign-conversion
- -Wsign-promo
- -Wstrict-null-sentinel
- -Wstrict-overflow=5
- -Wswitch-default
- -Wundef
- -Werror
- -Wno-unused
- -std=c++23
Compiler: g++
CompilationDatabase: build

View File

@ -10,6 +10,22 @@ set_target_properties(
OUTPUT_NAME "artichoke-c"
)
target_compile_options(
frontend PRIVATE
-pedantic
-Wall
-Wextra
-Wold-style-cast
-Wsign-conversion
-Wsign-promo
-Wstrict-null-sentinel
-Wstrict-overflow=5
-Wswitch-default
-Wundef
-Werror
-Wno-unused
)
target_include_directories(
frontend PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>

View File

@ -14,6 +14,22 @@ set_target_properties(
OUTPUT_NAME "artichoke"
)
target_compile_options(
library PRIVATE
-pedantic
-Wall
-Wextra
-Wold-style-cast
-Wsign-conversion
-Wsign-promo
-Wstrict-null-sentinel
-Wstrict-overflow=5
-Wswitch-default
-Wundef
-Werror
-Wno-unused
)
target_sources(
library PUBLIC
FILE_SET HEADERS

View File

@ -1,6 +1,7 @@
#include <artichoke/Tokenizer/Token.hpp>
#include <format>
#include <utility>
namespace arti::lang {
@ -186,7 +187,10 @@ namespace arti::lang {
return std::format("Token{{ {}, {} }}", "kwExport", value.strValue);
case kwModule:
return std::format("Token{{ {}, {} }}", "kwModule", value.strValue);
default:
return "<Undefined>";
}
return "<Undefined>";
std::unreachable();
}
} // namespace arti::lang

View File

@ -134,7 +134,10 @@ namespace arti::lang {
}
}
coret Token{ .value = TokenV::tkEOF, .line = line, .column = column };
coret Token{ .value = TokenV::tkEOF,
.line = line,
.column = column,
.strValue = "" };
}
void Tokenizer::skip_whitespace() {
@ -146,7 +149,6 @@ namespace arti::lang {
column = 0;
line += 1;
break;
default: return;
}

View File

@ -16,7 +16,7 @@ namespace arti::lang {
auto deallocator = [](char *mem) {
if (mem) {
free((void *) mem);
free(static_cast<void *>(mem));
}
};
@ -44,6 +44,7 @@ namespace arti::lang {
switch(ec) {
case ecMemAlloc: return "Memory allocation failed";
case ecInvalid: return "Invalid argument";
default: std::unreachable(); break;
}
std::unreachable();