-Wexport-undefined warning for exporting undefined symbols

This commit is contained in:
Rangi42
2025-08-24 16:52:20 -04:00
parent 62d3b44768
commit 8564df51e5
8 changed files with 23 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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 },