Bug 80552 - Make consecutive relative line numbers more maintainable
Summary: Make consecutive relative line numbers more maintainable
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: 7.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-28 08:30 UTC by Tom de Vries
Modified: 2021-12-24 14:04 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-12-24 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-04-28 08:30:49 UTC
[ Spinoff from PR80221: "Contrib script to rewrite testcase from absolute to relative line numbers" ]

We have patterns using relative line numbers in dg directives like this in gcc/testsuite/obj-c++.dg/class-extension-2.mm:
...
@implementation MyObject2
@end /* { dg-warning "incomplete implementation of class .MyObject2." } */
     /* { dg-warning "method definition for .-test. not found" "" { target *-*-* } .-1 } */
     /* { dg-warning "class .MyObject2. does not fully implement the .MyProtocol. protocol" "" { target *-*-* } .-2 } */
     /* { dg-warning "method definition for .-test2. not found" "" { target *-*-* } .-3 } */
     /* { dg-warning "class .MyObject2. does not fully implement the .MyProtocol2. protocol" "" { target *-*-* } .-4 } */
     /* { dg-warning "method definition for .-test3. not found" "" { target *-*-* } .-5 } */
     /* { dg-warning "class .MyObject2. does not fully implement the .MyProtocol3. protocol" "" { target *-*-* } .-6 } */
...

A few ideas were generated in PR80221 to deal with this in a less verbose and more maintainable fashion.

PR80221 comment 7:
...
  foobar;
  /* { dg-warning "warning for foobar" continue }
     { dg-warning "another warning for foobar" continue }
     { dg-error "error for foobar" } */
...

PR80221 comment 10:
...
    foobar;
    /* { dg-warning "warning for foobar" .-1 }
       Bla, bla, reasoning.
       { dg-warning "another warning for foobar" continue }
       Bla, bla, more reasoning.
       { dg-error "error for foobar" continue } */
...

PR80221 comment 11:
...
    foobar;
    /* { dg-begin-same-line-output .-1 }
       ...
       { dg-warning "warning for foobar" }
       ...
       { dg-message "note for foobar" }
       ...
       { dg-error "error for foobar" }
       ...
       { dg-end-same-line-output }  */
...
Comment 1 Tom de Vries 2017-04-28 08:40:11 UTC
FTR, a way to deal with the consecutive relative line numbers pattern using dg-line would be:
...
 foobar; /* { dg-line foobar_line } */
  /* { dg-warning "warning for foobar" foobar_line }
     { dg-warning "another warning for foobar" foobar_line }
     { dg-error "error for foobar" foobar_line } */
...
but that requires you to come up with a variable name for the line. It's better to have a solution that can be applied mechanically.
Comment 2 Andrew Pinski 2021-12-24 14:04:43 UTC
Confirmed.