https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80219

            Bug ID: 80219
           Summary: relative line numbers only working if
                    gcc_{error,warning}_prefix defined
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

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 "
...

Reply via email to