diff --git a/releasenotes.md b/releasenotes.md index ab06835a6..a51605fbd 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -15,6 +15,7 @@ - Improve ordering of method registration to support adding methods to generic modules with method constraints #1746 - Support experimental `@operator(construct)` operator overload. - Allow using 'var' to declare lambdas in functions. +- Add 'warnings' setting and make dead code a warning. ### Fixes - Fix case trying to initialize a `char[*]*` from a String. diff --git a/src/build/build.h b/src/build/build.h index eba59c34f..12c160967 100644 --- a/src/build/build.h +++ b/src/build/build.h @@ -148,6 +148,14 @@ typedef enum PANIC_ON = 1, } PanicLevel; +typedef enum +{ + WARNING_NOT_SET = -1, + WARNING_NORMAL = 0, + WARNING_ERROR = 1, + WARNING_OBNOXIOUS = 2, +} WarningLevel; + typedef enum { SINGLE_MODULE_NOT_SET = -1, @@ -443,6 +451,7 @@ typedef struct BuildOptions_ const char *vendor_download_path; const char *template; LinkerType linker_type; + WarningLevel warning_level; const char *custom_linker_path; uint32_t symtab_size; unsigned version; @@ -610,6 +619,7 @@ typedef struct MemoryEnvironment memory_environment; SizeOptimizationLevel optsize; SingleModule single_module; + WarningLevel warning_level; UseStdlib use_stdlib; EmitStdlib emit_stdlib; LinkLibc link_libc; @@ -699,6 +709,7 @@ static BuildTarget default_build_target = { .link_libc = LINK_LIBC_NOT_SET, .emit_stdlib = EMIT_STDLIB_NOT_SET, .linker_type = LINKER_TYPE_NOT_SET, + .warning_level = WARNING_NOT_SET, .single_module = SINGLE_MODULE_NOT_SET, .unroll_loops = UNROLL_LOOPS_NOT_SET, .merge_functions = MERGE_FUNCTIONS_NOT_SET, diff --git a/src/build/build_internal.h b/src/build/build_internal.h index 5d9227a7c..fa90a6c14 100644 --- a/src/build/build_internal.h +++ b/src/build/build_internal.h @@ -94,6 +94,12 @@ static const char *backends[3] = { [BACKEND_C] = "c", }; +static const char *warnings[3] = { + [WARNING_NORMAL] = "normal", + [WARNING_ERROR] = "error", + [WARNING_OBNOXIOUS] = "obnoxious", +}; + static const char *backtrace_levels[2] = { [SHOW_BACKTRACE_OFF] = "off", [SHOW_BACKTRACE_ON] = "on", diff --git a/src/build/build_options.c b/src/build/build_options.c index a4060b91f..e92af2d9c 100644 --- a/src/build/build_options.c +++ b/src/build/build_options.c @@ -97,6 +97,7 @@ static void usage(bool full) PRINTF(" --lib - Add this c3l library to the compilation."); if (full) { + PRINTF(" --warnings=