Relative line numbers for dg-{warning,error,bogus,message} are handled in gcc-dg.exp:process-message. dg-message is a gcc native construct, and uses process-message. dg-error and dg-bogus are overridden to use process-message, if gcc_error_prefix is defined (and save-dg-error is not already defined). dg-warning is overridden to use process-message, if gcc_warning_prefix is defined (and save-dg-warning is not already defined). Consequently, for testcases that are run from a .exp file not setting gcc_{error,warning}_prefix, using relative line numbers in dg-{warning,error,bogus} doesn't work. F.i., this doesn't work: ... diff --git a/gcc/testsuite/gnat.dg/warn4.adb b/gcc/testsuite/gnat.dg/warn4.adb index 94147c1..db21a42 100644 --- a/gcc/testsuite/gnat.dg/warn4.adb +++ b/gcc/testsuite/gnat.dg/warn4.adb @@ -12,7 +12,7 @@ procedure Warn4 is type POSIX_String_Ptr is access all POSIX_String; function sptr_to_psptr is new Unchecked_Conversion -- { dg-warning "aliasing problem" } - (String_Ptr, POSIX_String_Ptr); -- { dg-warning "" "" { target *-*-* } 14 } + (String_Ptr, POSIX_String_Ptr); -- { dg-warning "" "" { target *-*-* } .-1 } function To_POSIX_String (Str : String) return POSIX_String; function To_POSIX_String (Str : String) ... We get: ... ERROR: gnat.dg/warn4.adb: expected integer but got ".-1" for " dg-warning 15 "" "" { target *-*-* } .-1 " UNRESOLVED: gnat.dg/warn4.adb: expected integer but got ".-1" for " dg-warning 15 "" "" { target *-*-* } .-1 " ...
The master branch has been updated by Thomas Schwinge <tschwinge@gcc.gnu.org>: https://gcc.gnu.org/g:528507fa0314c75d1105890e4781a475c8badd7c commit r11-4607-g528507fa0314c75d1105890e4781a475c8badd7c Author: Thomas Schwinge <thomas@codesourcery.com> Date: Thu Oct 29 10:29:19 2020 +0100 libgomp testsuite: tell warning from error diagnostics, etc. [PR80219, PR85303] This changes makes 'dg-warning', 'dg-error', 'dg-bogus', 'dg-message' behave as expected, and also enables use of relative line numbers as well as 'dg-line'. libgomp/ PR testsuite/80219 PR testsuite/85303 * testsuite/lib/libgomp.exp (libgomp_init): Set 'gcc_warning_prefix', 'gcc_error_prefix'.
The releases/gcc-10 branch has been updated by Thomas Schwinge <tschwinge@gcc.gnu.org>: https://gcc.gnu.org/g:591e878fc6dd08502429a8e480d8e7d966836ca9 commit r10-8959-g591e878fc6dd08502429a8e480d8e7d966836ca9 Author: Thomas Schwinge <thomas@codesourcery.com> Date: Thu Oct 29 10:29:19 2020 +0100 libgomp testsuite: tell warning from error diagnostics, etc. [PR80219, PR85303] This changes makes 'dg-warning', 'dg-error', 'dg-bogus', 'dg-message' behave as expected, and also enables use of relative line numbers as well as 'dg-line'. libgomp/ PR testsuite/80219 PR testsuite/85303 * testsuite/lib/libgomp.exp (libgomp_init): Set 'gcc_warning_prefix', 'gcc_error_prefix'. (cherry picked from commit 528507fa0314c75d1105890e4781a475c8badd7c)
The releases/gcc-9 branch has been updated by Thomas Schwinge <tschwinge@gcc.gnu.org>: https://gcc.gnu.org/g:d824c5df1714403067f2a7170dd884887ce04712 commit r9-9017-gd824c5df1714403067f2a7170dd884887ce04712 Author: Thomas Schwinge <thomas@codesourcery.com> Date: Thu Oct 29 10:29:19 2020 +0100 libgomp testsuite: tell warning from error diagnostics, etc. [PR80219, PR85303] This changes makes 'dg-warning', 'dg-error', 'dg-bogus', 'dg-message' behave as expected, and also enables use of relative line numbers as well as 'dg-line'. libgomp/ PR testsuite/80219 PR testsuite/85303 * testsuite/lib/libgomp.exp (libgomp_init): Set 'gcc_warning_prefix', 'gcc_error_prefix'. (cherry picked from commit 528507fa0314c75d1105890e4781a475c8badd7c)
The releases/gcc-8 branch has been updated by Thomas Schwinge <tschwinge@gcc.gnu.org>: https://gcc.gnu.org/g:3940a3ff2be0b445a5b24a222e83669e570f32a9 commit r8-10603-g3940a3ff2be0b445a5b24a222e83669e570f32a9 Author: Thomas Schwinge <thomas@codesourcery.com> Date: Thu Oct 29 10:29:19 2020 +0100 libgomp testsuite: tell warning from error diagnostics, etc. [PR80219, PR85303] This changes makes 'dg-warning', 'dg-error', 'dg-bogus', 'dg-message' behave as expected, and also enables use of relative line numbers as well as 'dg-line'. libgomp/ PR testsuite/80219 PR testsuite/85303 * testsuite/lib/libgomp.exp (libgomp_init): Set 'gcc_warning_prefix', 'gcc_error_prefix'. (cherry picked from commit 528507fa0314c75d1105890e4781a475c8badd7c)
Fixed (only) for libgomp.
gcc_warning_prefix and gcc_error_prefix are still not set for the gnat testsuite.