[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-04-28 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #19 from Tom de Vries  ---
Filed spinoff PR80552 - "Make consecutive relative line numbers more
maintainable" to capture discussion related to 'continue' line and
dg-{begin,end}-same-line-output.

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-04-28 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #18 from Tom de Vries  ---
(In reply to Thomas Schwinge from comment #9)
> You could further optimize the script to omit "." locations: if the "dg-*"
> directive actually is placed on the appropriate line already.

I did this in a separate cleanup action, which I implemented using find and
sed.

Commited in r247363 "Remove superfluous ' . ' in
dg-(error|warning|message|bogus)".

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-04-28 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

Tom de Vries  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #17 from Tom de Vries  ---
I've written the script contrib/tests-rewrite-relative-line-number.py, and
committed the results of running it. The script itself is not committed, given
that we're not expecting to reuse it.

I've added the dg-line directive, so hopefully most of the remaining absolute
linenrs can be rewritten on a case-by-case-basis using either relative or saved
line nrs.

Given that the automated part of the effort is done, marking as resolved,
fixed.

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-04-21 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #16 from Tom de Vries  ---
Created attachment 41243
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41243=edit
tentative patch implementing dg-save-linenr

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-04-19 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #15 from Tom de Vries  ---
Author: vries
Date: Wed Apr 19 06:55:33 2017
New Revision: 246988

URL: https://gcc.gnu.org/viewcvs?rev=246988=gcc=rev
Log:
Use relative line number for subsequent dg directives

2017-04-19  Tom de Vries  

PR testsuite/80221
* c-c++-common/Wimplicit-fallthrough-6.c: Use relative line number for
subsequent dg directives.
* c-c++-common/Wimplicit-fallthrough-7.c: Same.
* c-c++-common/Wint-to-pointer-cast-3.c: Same.
* c-c++-common/attr-fallthrough-2.c: Same.
* c-c++-common/cilk-plus/AN/parser_errors2.c: Same.
* c-c++-common/cilk-plus/AN/parser_errors3.c: Same.
* c-c++-common/cilk-plus/AN/pr61191.c: Same.
* c-c++-common/cilk-plus/AN/pr61963.c: Same.
* c-c++-common/cilk-plus/AN/pr62008.c: Same.
* c-c++-common/cilk-plus/AN/rank_mismatch.c: Same.
* c-c++-common/cilk-plus/CK/cilk_for_errors.c: Same.
* c-c++-common/cilk-plus/CK/errors.c: Same.
* c-c++-common/cilk-plus/CK/no_args_error.c: Same.
* c-c++-common/cilk-plus/PS/clauses1.c: Same.
* c-c++-common/cilk-plus/SE/vlength_errors.c: Same.
* c-c++-common/cpp/pr57580.c: Same.
* c-c++-common/goacc/asyncwait-1.c: Same.
* c-c++-common/goacc/cache-2.c: Same.
* c-c++-common/goacc/declare-2.c: Same.
* c-c++-common/goacc/deviceptr-1.c: Same.
* c-c++-common/goacc/routine-5.c: Same.
* c-c++-common/gomp/clauses-2.c: Same.
* c-c++-common/gomp/ordered-3.c: Same.
* c-c++-common/gomp/pr67501.c: Same.
* c-c++-common/pr2.c: Same.
* c-c++-common/pr43395.c: Same.
* c-c++-common/pr49706.c: Same.
* c-c++-common/pr77624-1.c: Same.
* c-c++-common/pr77624-2.c: Same.
* c-c++-common/raw-string-14.c: Same.
* c-c++-common/raw-string-16.c: Same.
* c-c++-common/raw-string-3.c: Same.
* c-c++-common/raw-string-4.c: Same.
* c-c++-common/raw-string-5.c: Same.
* c-c++-common/raw-string-6.c: Same.
* g++.dg/abi/mangle41.C: Same.
* g++.dg/conversion/nullptr1.C: Same.
* g++.dg/cpp0x/alias-decl-80296.C: Same.
* g++.dg/cpp0x/auto27.C: Same.
* g++.dg/cpp0x/constexpr-98.C: Same.
* g++.dg/cpp0x/constexpr-diag2.C: Same.
* g++.dg/cpp0x/diag2.C: Same.
* g++.dg/cpp0x/lambda/lambda-syntax1.C: Same.
* g++.dg/cpp0x/nullptr15.C: Same.
* g++.dg/cpp0x/pr31431-2.C: Same.
* g++.dg/cpp0x/pr31431.C: Same.
* g++.dg/cpp0x/pr79118.C: Same.
* g++.dg/cpp0x/static_assert3.C: Same.
* g++.dg/cpp0x/temp_default2.C: Same.
* g++.dg/cpp0x/trailing4.C: Same.
* g++.dg/cpp0x/variadic-ex10.C: Same.
* g++.dg/cpp0x/variadic-ex13.C: Same.
* g++.dg/cpp0x/variadic-ex14.C: Same.
* g++.dg/cpp0x/variadic-ex3.C: Same.
* g++.dg/cpp0x/variadic-ex4.C: Same.
* g++.dg/cpp0x/variadic59.C: Same.
* g++.dg/cpp0x/vt-37737-2.C: Same.
* g++.dg/cpp0x/vt-57397-1.C: Same.
* g++.dg/cpp0x/vt-57397-2.C: Same.
* g++.dg/cpp1z/constexpr-lambda8.C: Same.
* g++.dg/cpp1z/gen-attrs1.C: Same.
* g++.dg/diagnostic/pr71075.C: Same.
* g++.dg/eh/goto2.C: Same.
* g++.dg/eh/goto3.C: Same.
* g++.dg/expr/bitfield4.C: Same.
* g++.dg/expr/bitfield5.C: Same.
* g++.dg/expr/bitfield6.C: Same.
* g++.dg/expr/bool1.C: Same.
* g++.dg/expr/bool3.C: Same.
* g++.dg/expr/cond10.C: Same.
* g++.dg/expr/cond11.C: Same.
* g++.dg/expr/lval3.C: Same.
* g++.dg/expr/lval4.C: Same.
* g++.dg/ext/anon-struct4.C: Same.
* g++.dg/ext/attrib44.C: Same.
* g++.dg/ext/builtin3.C: Same.
* g++.dg/ext/dllimport7.C: Same.
* g++.dg/ext/label5.C: Same.
* g++.dg/ext/no-asm-1.C: Same.
* g++.dg/ext/utf16-4.C: Same.
* g++.dg/ext/vla2.C: Same.
* g++.dg/gomp/block-1.C: Same.
* g++.dg/gomp/block-2.C: Same.
* g++.dg/gomp/block-3.C: Same.
* g++.dg/gomp/block-5.C: Same.
* g++.dg/gomp/linear-2.C: Same.
* g++.dg/gomp/target-1.C: Same.
* g++.dg/gomp/target-2.C: Same.
* g++.dg/gomp/taskgroup-1.C: Same.
* g++.dg/gomp/teams-1.C: Same.
* g++.dg/inherit/pure1.C: Same.
* g++.dg/init/array43.C: Same.
* g++.dg/init/array46.C: Same.
* g++.dg/init/const10.C: Same.
* g++.dg/init/ctor4-1.C: Same.
* g++.dg/init/ctor4.C: Same.
* g++.dg/init/new37.C: Same.
* g++.dg/init/pr25811.C: Same.
* g++.dg/init/pr29043.C: Same.
* g++.dg/init/pr29571.C: Same.
* g++.dg/lookup/duperr1.C: Same.
* g++.dg/lookup/error1.C: Same.
* g++.dg/lookup/koenig5.C: Same.
* g++.dg/lookup/pr77549.C: Same.
* 

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-04-18 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #14 from Tom de Vries  ---
Created attachment 41217
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41217=edit
Result from running updated script

Untested for now.

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-04-18 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #13 from Tom de Vries  ---
Created attachment 41216
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41216=edit
updated script patch

This updated patch rewrites a line from absolute to relative linenumber if:
- the relative line number is '.-1', '.' or '.+1', or
- it's adjacent to a line we will rewrite (with the line numbers being
  consecutive)

The biggest relative line number generated by the script is 6.

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-04-18 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #12 from Tom de Vries  ---
(In reply to Mike Stump from comment #6)
> The . and .-1, .+1, .-2 forms are fine.  The .-62 forms are as problematic
> as the original I suspect.  I think we should exclude any number greater
> than some small int, say, 9.  So, .-9 .. .+9 in the new form only.  If
> outside that range, I think I'd rather punt.  The idea is that the absolute
> number at least has a line number that in an editor you can go directly to,
> and it corresponds with the number in the error messages directly, aiding
> understanding which one is referred to without having to ungoop the relative
> number first.

I've run the script with the range abs(rellinenr) >= 10, and looked at the
affected testcases.

I found gcc/testsuite/c-c++-common/Wshift-negative-value-1.c, where a dg-error
is added on the last line of the test-case, but it seems more suited to be
added after the line generating the error. [ Perhaps this adding on last line
is a pattern that has been used to avoid the problem of tests starting to fail
when adding a line where it's appropriate due to using absolute line numbers. ]

I also found gcc/testsuite/objc.dg/try-catch-12.m:
...
12  extern void some_func (int *);
13  
14  @implementation TestMyTests
15  - (void) testSpoon {
16volatile int i = 5;
17int q = 99;
18  
19do {
20  @try {
21typeof(i) j = 6;
22typeof(q) k = 66;
23some_func (); /* { dg-warning "discards .volatile. qualifier
from pointer target type" } */
24/* { dg-message "but argument is of type" "" { target *-*-* } 12
} */
 ...

The dg-message on line 24 with line argument 12 refers back to the declaration
of some_func.

Using the relative line number for this sort of example doesn't make sense,
given the large distance there can be between decl and use. But keeping the
absolute line number also keeps the problem of tests starting to fail when you
add a line at the start. I think this sort of example is better handled with a
directive dg-save-linenr:
...
12  extern void some_func (int *); /* { dg-save-linenr some_func_decl } */
13  
14  @implementation TestMyTests
15  - (void) testSpoon {
16volatile int i = 5;
17int q = 99;
18  
19do {
20  @try {
21typeof(i) j = 6;
22typeof(q) k = 66;
23some_func (); /* { dg-warning "discards .volatile. qualifier
from pointer target type" } */
24/* { dg-message "but argument is of type" "" { target *-*-* }
$some_func_decl } */

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-04-18 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221
Bug 80221 depends on bug 80220, which changed state.

Bug 80220 Summary: relative line numbers don't work when put between braces
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80220

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |WONTFIX

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-28 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #11 from Martin Sebor  ---
That would work too.  Yet another possibility is to surround all the dg-message
directives that apply to the same line in a pair of new directives (analogously
to dg-{begin,end}-multiline-output):

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 }  */

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-28 Thread tschwinge at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #10 from Thomas Schwinge  ---
(In reply to Martin Sebor from comment #7)
> A more robust solution that wouldn't have to subject to a limit would be to
> add an annotation to dg-{error,message,warning} to indicate that the next
> dg-{bogus,error,message,warning} directive is meant to be applied to the
> same line as the current one.  For instance, something like this:

Instead of working "into the future"...

>   foobar;
>   /* { dg-warning "warning for foobar" continue }
>  { dg-warning "another warning for foobar" continue }
>  { dg-error "error for foobar" } */
> 
> (For brevity I omitted the comment and the { target ... } parts of the
> directives above.  It would also be nice to be able to do away with those
> when they're not necessary.)

..., perhaps it's easier to implement that idea the other way round: at the end
of a "dg-*" handling routine, store the current location into a global
variable, and if a later "dg-*" directive uses a "continue" location, use the
value of the global variable instead.  That is:

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 } */

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-28 Thread tschwinge at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

Thomas Schwinge  changed:

   What|Removed |Added

 CC||tschwinge at gcc dot gnu.org

--- Comment #8 from Thomas Schwinge  ---
(In reply to Mike Stump from comment #6)
> The . and .-1, .+1, .-2 forms are fine.  The .-62 forms are as problematic
> as the original I suspect.  I think we should exclude any number greater
> than some small int, say, 9.  So, .-9 .. .+9 in the new form only.  If
> outside that range, I think I'd rather punt.  The idea is that the absolute
> number at least has a line number that in an editor you can go directly to,
> and it corresponds with the number in the error messages directly, aiding
> understanding which one is referred to without having to ungoop the relative
> number first.

I would guess that a lange number of these are actually cases where all the
"dg-*" directives have been assembled at the end of the file?  In such cases,
it would perhaps make sense to move them onto or next to the lines they apply
to -- unless that doesn't make sense for other reasons (when they are grouped
together for a reason).

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-28 Thread tschwinge at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #9 from Thomas Schwinge  ---
You could further optimize the script to omit "." locations: if the "dg-*"
directive actually is placed on the appropriate line already.

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-27 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

Martin Sebor  changed:

   What|Removed |Added

 CC||msebor at gcc dot gnu.org

--- Comment #7 from Martin Sebor  ---
A more robust solution that wouldn't have to subject to a limit would be to add
an annotation to dg-{error,message,warning} to indicate that the next
dg-{bogus,error,message,warning} directive is meant to be applied to the same
line as the current one.  For instance, something like this:

  foobar;
  /* { dg-warning "warning for foobar" continue }
 { dg-warning "another warning for foobar" continue }
 { dg-error "error for foobar" } */

(For brevity I omitted the comment and the { target ... } parts of the
directives above.  It would also be nice to be able to do away with those when
they're not necessary.)

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-27 Thread mikestump at comcast dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #6 from Mike Stump  ---
Comment on attachment 41059
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41059
Result from running script

The . and .-1, .+1, .-2 forms are fine.  The .-62 forms are as problematic as
the original I suspect.  I think we should exclude any number greater than some
small int, say, 9.  So, .-9 .. .+9 in the new form only.  If outside that
range, I think I'd rather punt.  The idea is that the absolute number at least
has a line number that in an editor you can go directly to, and it corresponds
with the number in the error messages directly, aiding understanding which one
is referred to without having to ungoop the relative number first.

Let's see if anyone else has any comments.  If not, I'd pre-approve the change
with the range reduced.

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-27 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #5 from Tom de Vries  ---
(In reply to Tom de Vries from comment #3)
> Created attachment 41058 [details]
> tested patch

tested in combination with fix for PR80220.

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-27 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #4 from Tom de Vries  ---
Created attachment 41059
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41059=edit
Result from running script

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-27 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

Tom de Vries  changed:

   What|Removed |Added

  Attachment #41057|0   |1
is obsolete||

--- Comment #3 from Tom de Vries  ---
Created attachment 41058
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41058=edit
tested patch

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-27 Thread mikestump at comcast dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

Mike Stump  changed:

   What|Removed |Added

 CC||mikestump at comcast dot net

--- Comment #2 from Mike Stump  ---
Look forward to incorporating the changes made by the script.

[Bug testsuite/80221] Contrib script to rewrite testcase from absolute to relative line numbers

2017-03-27 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80221

--- Comment #1 from Tom de Vries  ---
Created attachment 41057
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41057=edit
tentative patch

This script tries to rewrite all tests, but that's not entirely supported yet.

Known error causes:
- PR80219 relative line numbers only working if gcc_{error,warning}_prefix
  defined
- PR80220 relative line numbers don't work when put between braces