mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 02:02:06 +00:00
-Wexport-undefined warning for exporting undefined symbols
This commit is contained in:
@@ -184,6 +184,7 @@ _rgbasm_completions() {
|
||||
empty-data-directive
|
||||
empty-macro-arg
|
||||
empty-strrpl
|
||||
export-undefined
|
||||
large-constant
|
||||
macro-shift
|
||||
nested-comment
|
||||
|
||||
@@ -16,6 +16,7 @@ _rgbasm_warnings() {
|
||||
'empty-data-directive:Warn on arg-less d[bwl] in ROM'
|
||||
'empty-macro-arg:Warn on empty macro arg'
|
||||
'empty-strrpl:Warn on calling STRRPL with empty pattern'
|
||||
'export-undefined:Warn on EXPORT of an undefined symbol'
|
||||
'large-constant:Warn on constants too large for a signed 32-bit int'
|
||||
'macro-shift:Warn when shifting macro args part their limits'
|
||||
'nested-comment:Warn on "/*" inside block comments'
|
||||
|
||||
@@ -23,6 +23,7 @@ enum WarningID {
|
||||
WARNING_EMPTY_DATA_DIRECTIVE, // `db`, `dw` or `dl` directive without data in ROM
|
||||
WARNING_EMPTY_MACRO_ARG, // Empty macro argument
|
||||
WARNING_EMPTY_STRRPL, // Empty second argument in `STRRPL`
|
||||
WARNING_EXPORT_UNDEFINED, // `EXPORT` of an undefined symbol
|
||||
WARNING_LARGE_CONSTANT, // Constants too large
|
||||
WARNING_MACRO_SHIFT, // `SHIFT` past available arguments in macro
|
||||
WARNING_NESTED_COMMENT, // Comment-start delimiter in a block comment
|
||||
|
||||
@@ -394,6 +394,10 @@ Warn when
|
||||
is called with an empty string as its second argument (the substring to replace).
|
||||
This warning is enabled by
|
||||
.Fl Wall .
|
||||
.It Fl Wexport-undefined
|
||||
Warn when exporting an undefined symbol.
|
||||
This warning is enabled by
|
||||
.Fl Wall .
|
||||
.It Fl Wno-large-constant
|
||||
Warn when a constant too large to fit in a signed 32-bit integer is encountered.
|
||||
.It Fl Wmacro-shift
|
||||
|
||||
@@ -611,7 +611,7 @@ void sym_Export(std::string const &symName) {
|
||||
if (symName.starts_with('!')) {
|
||||
// LCOV_EXCL_START
|
||||
// The parser does not accept anonymous labels for an `EXPORT` directive
|
||||
error("Anonymous labels cannot be exported");
|
||||
error("Cannot export anonymous label");
|
||||
return;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
@@ -620,8 +620,10 @@ void sym_Export(std::string const &symName) {
|
||||
|
||||
// If the symbol doesn't exist, create a ref that can be purged
|
||||
if (!sym) {
|
||||
warning(WARNING_EXPORT_UNDEFINED, "Exporting an undefined symbol `%s`", symName.c_str());
|
||||
sym = sym_Ref(symName);
|
||||
}
|
||||
|
||||
sym->isExported = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ Diagnostics<WarningLevel, WarningID> warnings = {
|
||||
{"empty-data-directive", LEVEL_ALL },
|
||||
{"empty-macro-arg", LEVEL_EXTRA },
|
||||
{"empty-strrpl", LEVEL_ALL },
|
||||
{"export-undefined", LEVEL_ALL },
|
||||
{"large-constant", LEVEL_DEFAULT },
|
||||
{"macro-shift", LEVEL_EXTRA },
|
||||
{"nested-comment", LEVEL_DEFAULT },
|
||||
|
||||
@@ -16,3 +16,6 @@ EXPORT REDEF variable = 1234
|
||||
DEF equs_sym EQUS "hello"
|
||||
EXPORT equs_sym ; exports undefined symbol `hello` due to EQUS expansion
|
||||
EXPORT DEF string EQUS "goodbye" ; invalid syntax
|
||||
|
||||
PURGE equ_sym
|
||||
EXPORT equ_sym
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
warning: Exporting an undefined symbol `undefined` [-Wexport-undefined]
|
||||
at export.asm(1)
|
||||
warning: Exporting an undefined symbol `hello` [-Wexport-undefined]
|
||||
at export.asm(17)
|
||||
while expanding symbol `equs_sym`
|
||||
error: syntax error, unexpected EQUS
|
||||
at export.asm(18)
|
||||
warning: Purging an exported symbol `equ_sym` [-Wpurge]
|
||||
at export.asm(20)
|
||||
warning: Exporting an undefined symbol `equ_sym` [-Wexport-undefined]
|
||||
at export.asm(21)
|
||||
Assembly aborted with 1 error!
|
||||
|
||||
Reference in New Issue
Block a user