This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug testsuite/80220] New: relative line numbers don't work when put between braces


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

            Bug ID: 80220
           Summary: relative line numbers don't work when put between
                    braces
           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: ---

Consider src/gcc/testsuite/gcc.dg/990506-0.c:
...
$ cat -n 990506-0.c
     1  /* Verify that a diagnostic is issued without crashing due to
     2     --enable-checking catching a bug in the C front end.  */
     3  /* { dg-do compile } */
     4  x()
     5  {
     6    foo (i);
     7    /* { dg-error "undeclared" "undeclared-variable message" { target
*-*-* } { 6 } } */
     8    /* { dg-message "function it appears in" "reminder message" { target
*-*-* } { 6 } } */ 
     9  }

...

When we rewrite the test to use relative line numbers:
...
diff --git a/gcc/testsuite/gcc.dg/990506-0.c b/gcc/testsuite/gcc.dg/990506-0.c
index 3cd3be3..08ba856 100644
--- a/gcc/testsuite/gcc.dg/990506-0.c
+++ b/gcc/testsuite/gcc.dg/990506-0.c
@@ -4,6 +4,6 @@
 x()
 {
   foo (i);
-  /* { dg-error "undeclared" "undeclared-variable message" { target *-*-* } {
6 } } */
-  /* { dg-message "function it appears in" "reminder message" { target *-*-* }
{ 6 } } */
+  /* { dg-error "undeclared" "undeclared-variable message" { target *-*-* } {
.-1 } } */
+  /* { dg-message "function it appears in" "reminder message" { target *-*-* }
{ .-2 } } */
 }
...

we run into trouble:
...
ERROR: gcc.dg/990506-0.c: expected integer but got " .-1 " for " dg-error 7
"undeclared" "undeclared-variable message" { target *-*-* } { .-1 } "
UNRESOLVED: gcc.dg/990506-0.c: expected integer but got " .-1 " for " dg-error
7 "undeclared" "undeclared-variable message" { target *-*-* } { .-1 } "
...

The problem is that the relative line number is written between braces, which
results in whitespace before and after the number, and the relative line number
handling in process-message doesn't handle that whitespace well.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]