Bug 80219 - relative line numbers only working if gcc_{error,warning}_prefix defined
Summary: relative line numbers only working if gcc_{error,warning}_prefix defined
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-27 12:35 UTC by Tom de Vries
Modified: 2024-04-11 03:10 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-11-02 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2017-03-27 12:35:41 UTC
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 "
...
Comment 1 GCC Commits 2020-11-02 13:26:23 UTC
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'.
Comment 2 GCC Commits 2020-11-02 13:28:37 UTC
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)
Comment 3 GCC Commits 2020-11-02 13:30:31 UTC
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)
Comment 4 GCC Commits 2020-11-02 13:30:45 UTC
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)
Comment 5 Thomas Schwinge 2020-11-02 13:36:49 UTC
Fixed (only) for libgomp.
Comment 6 Andrew Pinski 2024-04-11 03:10:42 UTC
gcc_warning_prefix and gcc_error_prefix are still not set for the gnat testsuite.