From de36a11be7713c4ab46051d4d896b2567a9f84be Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 4 Jul 2026 22:41:55 -0400 Subject: [PATCH] Prevent `rgblink -Wno-*` disabled warnings from printing a location trace anyway Fixes #2005 --- docs/CONTRIBUTING.md | 4 ++++ src/link/warning.cpp | 4 +++- test/link/no-large-constant.asm | 2 ++ test/link/no-large-constant.flags | 1 + test/link/no-large-constant.link | 2 ++ test/link/no-large-constant.out | 3 +++ test/link/test.sh | 13 +++++++++---- 7 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 test/link/no-large-constant.asm create mode 100644 test/link/no-large-constant.flags create mode 100644 test/link/no-large-constant.link create mode 100644 test/link/no-large-constant.out diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index bd982aa7..5cbadc62 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -142,6 +142,10 @@ linked in various ways depending on the test. These simply check that RGBLINK's output matches some expected output. +If a `.flags` file exists, its first line contains flags to pass to RGBLINK. +(There may be more lines, which will be ignored; they can serve as comments to +explain what the test is about.) + A `.out` file **must** exist, and RGBLINK's total output must match that file's contents. diff --git a/src/link/warning.cpp b/src/link/warning.cpp index a9b85b7e..5c4898cf 100644 --- a/src/link/warning.cpp +++ b/src/link/warning.cpp @@ -212,16 +212,18 @@ void scriptWarning(WarningID id, char const *fmt, ...) { case WarningBehavior::ENABLED: printDiag(nullptr, 0, fmt, args, "warning", STYLE_YELLOW, "[-W%s]", flag); + + lexer_TraceCurrent(); break; case WarningBehavior::ERROR: printDiag(nullptr, 0, fmt, args, "error", STYLE_RED, "[-Werror=%s]", flag); + lexer_TraceCurrent(); warnings.incrementErrors(); break; } va_end(args); - lexer_TraceCurrent(); } diff --git a/test/link/no-large-constant.asm b/test/link/no-large-constant.asm new file mode 100644 index 00000000..b11e697f --- /dev/null +++ b/test/link/no-large-constant.asm @@ -0,0 +1,2 @@ +section "test", romx +label: dw label diff --git a/test/link/no-large-constant.flags b/test/link/no-large-constant.flags new file mode 100644 index 00000000..e4be9de2 --- /dev/null +++ b/test/link/no-large-constant.flags @@ -0,0 +1 @@ +-Wno-large-constant diff --git a/test/link/no-large-constant.link b/test/link/no-large-constant.link new file mode 100644 index 00000000..9420405f --- /dev/null +++ b/test/link/no-large-constant.link @@ -0,0 +1,2 @@ +ROMX $ffff_ffff_ffff_ffff + "test" diff --git a/test/link/no-large-constant.out b/test/link/no-large-constant.out new file mode 100644 index 00000000..406acce2 --- /dev/null +++ b/test/link/no-large-constant.out @@ -0,0 +1,3 @@ +error: ROMX bank 0 does not exist (the minimum is 1) + at no-large-constant.link(1) +Linking failed with 1 error diff --git a/test/link/test.sh b/test/link/test.sh index d098efa0..0b5cdb51 100755 --- a/test/link/test.sh +++ b/test/link/test.sh @@ -93,19 +93,24 @@ for i in *.asm; do startTest "$RGBASM" -o "$otemp" "${test}.asm" + RGBLINKFLAGS="" + if [ -f "${test}.flags" ]; then + RGBLINKFLAGS="$RGBLINKFLAGS @${test}.flags" + fi + # Some tests have variants depending on flags ran_flag=false for flag in '-d' '-t' '-w'; do if [ -f "${test}-no${flag}.out" ]; then continueTest "-no${flag}" - rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$outtemp" + rgblinkQuiet $RGBLINKFLAGS -o "$gbtemp" "$otemp" 2>"$outtemp" tryDiff "${test}-no${flag}.out" "$outtemp" evaluateTest ran_flag=true fi if [ -f "${test}${flag}.out" ]; then continueTest "$flag" - rgblinkQuiet ${flag} -o "$gbtemp" "$otemp" 2>"$outtemp" + rgblinkQuiet $RGBLINKFLAGS ${flag} -o "$gbtemp" "$otemp" 2>"$outtemp" tryDiff "${test}${flag}.out" "$outtemp" evaluateTest ran_flag=true @@ -120,7 +125,7 @@ for i in *.asm; do [[ -e "$script" ]] || break # If the glob doesn't match, it just... doesn't expand! continueTest "${script#${test}}" - rgblinkQuiet -l "$script" -o "$gbtemp" "$otemp" 2>"$outtemp" + rgblinkQuiet $RGBLINKFLAGS -l "$script" -o "$gbtemp" "$otemp" 2>"$outtemp" tryDiff "${script%.link}.out" "$outtemp" evaluateTest ran_flag=true @@ -131,7 +136,7 @@ for i in *.asm; do # The rest of the tests just links a file, and maybe checks the binary continueTest - rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$outtemp" + rgblinkQuiet $RGBLINKFLAGS -o "$gbtemp" "$otemp" 2>"$outtemp" tryDiff "${test}.out" "$outtemp" bin=${test}.out.bin if [ -f "$bin" ]; then