testsuite: add lib/nn-line-numbers.exp

Message ID 20200108220714.15701-1-dmalcolm@redhat.com
State New
Headers show
Series
  • testsuite: add lib/nn-line-numbers.exp
Related show

Commit Message

David Malcolm Jan. 8, 2020, 10:07 p.m.
(replying to my own "[PATCH 05/41] Add -fdiagnostics-nn-line-numbers"
with a followup that does it at the DejaGnu level rather than as a
test-only option)

On Wed, 2020-01-08 at 04:02 -0500, David Malcolm wrote:
> I may be able to self-approve this.  It's used by the diagnostic_path

> patch, and by the analyzer test suite.  Perhaps better to make

> undocumeted, or do it via a DejaGnu pruning directive, but I wanted

> to get v5 of the kit posted.

> 

> This patch implements -fdiagnostics-nn-line-numbers, a new option

> which makes diagnostic_show_locus print "NN" rather than specific

> line numbers when printing the left margin.

> 

> This is intended purely to make it easier to write certain kinds of

> DejaGnu test; various integration tests for diagnostic paths later

> in the patch kit make use of it.

> 

> gcc/ChangeLog:

> 	* common.opt (fdiagnostics-nn-line-numbers): New option.

> 	* diagnostic-show-locus.c

> (layout::m_use_nn_for_line_numbers_p):

> 	New field.

> 	(layout::layout): Initialize it.

> 	(layout::calculate_linenum_width): Use it when computing

> 	m_linenum_width.

> 	(layout::print_source_line): Implement printing "NN" rather

> than

> 	the line number.

> 	(selftest::test_line_numbers_multiline_range): Add a test of

> "NN"

> 	printing.

> 	* diagnostic.c (diagnostic_initialize): Initialize

> 	use_nn_for_line_numbers_p.

> 	(num_digits): Add "use_nn_p" param.

> 	(selftest::test_num_digits): Add a test for use_nn_p==true.

> 	* diagnostic.h (diagnostic_context::use_nn_for_line_numbers_p):

> 	New field.

> 	(num_digits): Add optional "use_nn_p" param.

> 	* doc/invoke.texi (-fdiagnostics-nn-line-numbers): New option.

> 	* dwarf2out.c (gen_producer_string): Ignore

> 	OPT_fdiagnostics_nn_line_numbers.

> 	* lto-wrapper.c (merge_and_complain): Handle

> 	OPT_fdiagnostics_nn_line_numbers.

> 	(append_compiler_options): Likewise.

> 	(append_diag_options): Likewise.

> 	* opts.c (common_handle_option): Likewise.

> 	* toplev.c (general_init): Initialize

> 	global_dc->use_nn_for_line_numbers_p.


Here's an alterative patch to the above that replaces the
"-fdiagnostics-nn-line-numbers" option in earlier versions of the
analyzer patch kit, by doing it at the DejaGnu level instead.

This patch adds support for obscuring the line numbers printed in the
left-hand margin when printing the source code, converting them to NN,
e.g from:

  7111 |   if (!(flags & 0x0001)) {
       |      ^
       |      |
       |      (1) following 'true' branch...
  7112 |

to:

   NN  |   if (!(flags & 0x0001)) {
       |      ^
       |      |
       |      (1) following 'true' branch...
   NN  |

This is useful in followup patches e.g. when testing how interprocedural
paths are printed using multiline.exp, to avoid depending on precise line
numbers.

I'm testing this now (but it seems to be a working, drop-in replacement
for the option in the parts of the patch kit I've tested with it).

Examples of use can be seen in the analyzer test suite:
  https://gcc.gnu.org/ml/gcc-patches/2020-01/msg00320.html
(search for -fdiagnostics-nn-line-numbers and dg-begin-multiline-output
there to get the idea)

OK for trunk assuming the other testing looks good?

gcc/testsuite/ChangeLog:
	* lib/gcc-dg.exp (cleanup-after-saved-dg-test): Reset global
	nn_line_numbers_enabled.
	* lib/nn-line-numbers.exp: New file.
	* lib/prune.exp: Load nn-line-numbers.exp.
	(prune_gcc_output): Call maybe-handle-nn-line-numbers.
---
 gcc/testsuite/lib/gcc-dg.exp          |   2 +
 gcc/testsuite/lib/nn-line-numbers.exp | 103 ++++++++++++++++++++++++++
 gcc/testsuite/lib/prune.exp           |   5 ++
 3 files changed, 110 insertions(+)
 create mode 100644 gcc/testsuite/lib/nn-line-numbers.exp

-- 
2.21.0

Comments

Jeff Law Jan. 10, 2020, 3:35 p.m. | #1
On Wed, 2020-01-08 at 17:07 -0500, David Malcolm wrote:
> (replying to my own "[PATCH 05/41] Add -fdiagnostics-nn-line-numbers"

> with a followup that does it at the DejaGnu level rather than as a

> test-only option)

> 

> On Wed, 2020-01-08 at 04:02 -0500, David Malcolm wrote:

> > I may be able to self-approve this.  It's used by the diagnostic_path

> > patch, and by the analyzer test suite.  Perhaps better to make

> > undocumeted, or do it via a DejaGnu pruning directive, but I wanted

> > to get v5 of the kit posted.

> > 

> > This patch implements -fdiagnostics-nn-line-numbers, a new option

> > which makes diagnostic_show_locus print "NN" rather than specific

> > line numbers when printing the left margin.

> > 

> > This is intended purely to make it easier to write certain kinds of

> > DejaGnu test; various integration tests for diagnostic paths later

> > in the patch kit make use of it.

> > 

> > gcc/ChangeLog:

> > 	* common.opt (fdiagnostics-nn-line-numbers): New option.

> > 	* diagnostic-show-locus.c

> > (layout::m_use_nn_for_line_numbers_p):

> > 	New field.

> > 	(layout::layout): Initialize it.

> > 	(layout::calculate_linenum_width): Use it when computing

> > 	m_linenum_width.

> > 	(layout::print_source_line): Implement printing "NN" rather

> > than

> > 	the line number.

> > 	(selftest::test_line_numbers_multiline_range): Add a test of

> > "NN"

> > 	printing.

> > 	* diagnostic.c (diagnostic_initialize): Initialize

> > 	use_nn_for_line_numbers_p.

> > 	(num_digits): Add "use_nn_p" param.

> > 	(selftest::test_num_digits): Add a test for use_nn_p==true.

> > 	* diagnostic.h (diagnostic_context::use_nn_for_line_numbers_p):

> > 	New field.

> > 	(num_digits): Add optional "use_nn_p" param.

> > 	* doc/invoke.texi (-fdiagnostics-nn-line-numbers): New option.

> > 	* dwarf2out.c (gen_producer_string): Ignore

> > 	OPT_fdiagnostics_nn_line_numbers.

> > 	* lto-wrapper.c (merge_and_complain): Handle

> > 	OPT_fdiagnostics_nn_line_numbers.

> > 	(append_compiler_options): Likewise.

> > 	(append_diag_options): Likewise.

> > 	* opts.c (common_handle_option): Likewise.

> > 	* toplev.c (general_init): Initialize

> > 	global_dc->use_nn_for_line_numbers_p.

> 

> Here's an alterative patch to the above that replaces the

> "-fdiagnostics-nn-line-numbers" option in earlier versions of the

> analyzer patch kit, by doing it at the DejaGnu level instead.

> 

> This patch adds support for obscuring the line numbers printed in the

> left-hand margin when printing the source code, converting them to NN,

> e.g from:

> 

>   7111 |   if (!(flags & 0x0001)) {

>        |      ^

>        |      |

>        |      (1) following 'true' branch...

>   7112 |

> 

> to:

> 

>    NN  |   if (!(flags & 0x0001)) {

>        |      ^

>        |      |

>        |      (1) following 'true' branch...

>    NN  |

> 

> This is useful in followup patches e.g. when testing how interprocedural

> paths are printed using multiline.exp, to avoid depending on precise line

> numbers.

> 

> I'm testing this now (but it seems to be a working, drop-in replacement

> for the option in the parts of the patch kit I've tested with it).

> 

> Examples of use can be seen in the analyzer test suite:

>   https://gcc.gnu.org/ml/gcc-patches/2020-01/msg00320.html

> (search for -fdiagnostics-nn-line-numbers and dg-begin-multiline-output

> there to get the idea)

> 

> OK for trunk assuming the other testing looks good?

> 

> gcc/testsuite/ChangeLog:

> 	* lib/gcc-dg.exp (cleanup-after-saved-dg-test): Reset global

> 	nn_line_numbers_enabled.

> 	* lib/nn-line-numbers.exp: New file.

> 	* lib/prune.exp: Load nn-line-numbers.exp.

> 	(prune_gcc_output): Call maybe-handle-nn-line-numbers.

OK
jeff
>
David Malcolm Jan. 10, 2020, 4:44 p.m. | #2
On Fri, 2020-01-10 at 08:35 -0700, Jeff Law wrote:
> On Wed, 2020-01-08 at 17:07 -0500, David Malcolm wrote:

> > (replying to my own "[PATCH 05/41] Add -fdiagnostics-nn-line-

> > numbers"

> > with a followup that does it at the DejaGnu level rather than as a

> > test-only option)

> > 

> > On Wed, 2020-01-08 at 04:02 -0500, David Malcolm wrote:

> > > I may be able to self-approve this.  It's used by the

> > > diagnostic_path

> > > patch, and by the analyzer test suite.  Perhaps better to make

> > > undocumeted, or do it via a DejaGnu pruning directive, but I

> > > wanted

> > > to get v5 of the kit posted.

> > > 

> > > This patch implements -fdiagnostics-nn-line-numbers, a new option

> > > which makes diagnostic_show_locus print "NN" rather than specific

> > > line numbers when printing the left margin.

> > > 

> > > This is intended purely to make it easier to write certain kinds

> > > of

> > > DejaGnu test; various integration tests for diagnostic paths

> > > later

> > > in the patch kit make use of it.

> > > 

> > > gcc/ChangeLog:

> > > 	* common.opt (fdiagnostics-nn-line-numbers): New option.

> > > 	* diagnostic-show-locus.c

> > > (layout::m_use_nn_for_line_numbers_p):

> > > 	New field.

> > > 	(layout::layout): Initialize it.

> > > 	(layout::calculate_linenum_width): Use it when computing

> > > 	m_linenum_width.

> > > 	(layout::print_source_line): Implement printing "NN" rather

> > > than

> > > 	the line number.

> > > 	(selftest::test_line_numbers_multiline_range): Add a test of

> > > "NN"

> > > 	printing.

> > > 	* diagnostic.c (diagnostic_initialize): Initialize

> > > 	use_nn_for_line_numbers_p.

> > > 	(num_digits): Add "use_nn_p" param.

> > > 	(selftest::test_num_digits): Add a test for use_nn_p==true.

> > > 	* diagnostic.h (diagnostic_context::use_nn_for_line_numbers_p):

> > > 	New field.

> > > 	(num_digits): Add optional "use_nn_p" param.

> > > 	* doc/invoke.texi (-fdiagnostics-nn-line-numbers): New option.

> > > 	* dwarf2out.c (gen_producer_string): Ignore

> > > 	OPT_fdiagnostics_nn_line_numbers.

> > > 	* lto-wrapper.c (merge_and_complain): Handle

> > > 	OPT_fdiagnostics_nn_line_numbers.

> > > 	(append_compiler_options): Likewise.

> > > 	(append_diag_options): Likewise.

> > > 	* opts.c (common_handle_option): Likewise.

> > > 	* toplev.c (general_init): Initialize

> > > 	global_dc->use_nn_for_line_numbers_p.

> > 

> > Here's an alterative patch to the above that replaces the

> > "-fdiagnostics-nn-line-numbers" option in earlier versions of the

> > analyzer patch kit, by doing it at the DejaGnu level instead.

> > 

> > This patch adds support for obscuring the line numbers printed in

> > the

> > left-hand margin when printing the source code, converting them to

> > NN,

> > e.g from:

> > 

> >   7111 |   if (!(flags & 0x0001)) {

> >        |      ^

> >        |      |

> >        |      (1) following 'true' branch...

> >   7112 |

> > 

> > to:

> > 

> >    NN  |   if (!(flags & 0x0001)) {

> >        |      ^

> >        |      |

> >        |      (1) following 'true' branch...

> >    NN  |

> > 

> > This is useful in followup patches e.g. when testing how

> > interprocedural

> > paths are printed using multiline.exp, to avoid depending on

> > precise line

> > numbers.

> > 

> > I'm testing this now (but it seems to be a working, drop-in

> > replacement

> > for the option in the parts of the patch kit I've tested with it).

> > 

> > Examples of use can be seen in the analyzer test suite:

> >   https://gcc.gnu.org/ml/gcc-patches/2020-01/msg00320.html

> > (search for -fdiagnostics-nn-line-numbers and dg-begin-multiline-

> > output

> > there to get the idea)

> > 

> > OK for trunk assuming the other testing looks good?

> > 

> > gcc/testsuite/ChangeLog:

> > 	* lib/gcc-dg.exp (cleanup-after-saved-dg-test): Reset global

> > 	nn_line_numbers_enabled.

> > 	* lib/nn-line-numbers.exp: New file.

> > 	* lib/prune.exp: Load nn-line-numbers.exp.

> > 	(prune_gcc_output): Call maybe-handle-nn-line-numbers.

> OK

> jeff


Thanks.  It turned out that the above patch didn't work; as noted in:
  [PATCH] testsuite: add dg-enable-nn-line-numbers (v6)
    https://gcc.gnu.org/ml/gcc-patches/2020-01/msg00517.html
it turns out that the non-gcc parts of the testsuite that use prune.exp
need to jump through some hoops due to Tcl lib path issues needing to
preload libs by hacking in calls to load_gcc_lib, and at least one
(libgo.exp) is a mirrored copy that we're not the canonical copy of.

Given that this is meant to be used in conjunction with multiline.exp
the simplest fix was to move the code into multiline.exp, which I did
in the latter patch.

Presumably that latter version is also OK?  (it has the advantage of
actually successfully running...)

Thanks
Dave
Jeff Law Jan. 10, 2020, 5:45 p.m. | #3
On Fri, 2020-01-10 at 11:44 -0500, David Malcolm wrote:
> On Fri, 2020-01-10 at 08:35 -0700, Jeff Law wrote:

> > On Wed, 2020-01-08 at 17:07 -0500, David Malcolm wrote:

> > > (replying to my own "[PATCH 05/41] Add -fdiagnostics-nn-line-

> > > numbers"

> > > with a followup that does it at the DejaGnu level rather than as a

> > > test-only option)

> > > 

> > > On Wed, 2020-01-08 at 04:02 -0500, David Malcolm wrote:

> > > > I may be able to self-approve this.  It's used by the

> > > > diagnostic_path

> > > > patch, and by the analyzer test suite.  Perhaps better to make

> > > > undocumeted, or do it via a DejaGnu pruning directive, but I

> > > > wanted

> > > > to get v5 of the kit posted.

> > > > 

> > > > This patch implements -fdiagnostics-nn-line-numbers, a new option

> > > > which makes diagnostic_show_locus print "NN" rather than specific

> > > > line numbers when printing the left margin.

> > > > 

> > > > This is intended purely to make it easier to write certain kinds

> > > > of

> > > > DejaGnu test; various integration tests for diagnostic paths

> > > > later

> > > > in the patch kit make use of it.

> > > > 

> > > > gcc/ChangeLog:

> > > > 	* common.opt (fdiagnostics-nn-line-numbers): New option.

> > > > 	* diagnostic-show-locus.c

> > > > (layout::m_use_nn_for_line_numbers_p):

> > > > 	New field.

> > > > 	(layout::layout): Initialize it.

> > > > 	(layout::calculate_linenum_width): Use it when computing

> > > > 	m_linenum_width.

> > > > 	(layout::print_source_line): Implement printing "NN" rather

> > > > than

> > > > 	the line number.

> > > > 	(selftest::test_line_numbers_multiline_range): Add a test of

> > > > "NN"

> > > > 	printing.

> > > > 	* diagnostic.c (diagnostic_initialize): Initialize

> > > > 	use_nn_for_line_numbers_p.

> > > > 	(num_digits): Add "use_nn_p" param.

> > > > 	(selftest::test_num_digits): Add a test for use_nn_p==true.

> > > > 	* diagnostic.h (diagnostic_context::use_nn_for_line_numbers_p):

> > > > 	New field.

> > > > 	(num_digits): Add optional "use_nn_p" param.

> > > > 	* doc/invoke.texi (-fdiagnostics-nn-line-numbers): New option.

> > > > 	* dwarf2out.c (gen_producer_string): Ignore

> > > > 	OPT_fdiagnostics_nn_line_numbers.

> > > > 	* lto-wrapper.c (merge_and_complain): Handle

> > > > 	OPT_fdiagnostics_nn_line_numbers.

> > > > 	(append_compiler_options): Likewise.

> > > > 	(append_diag_options): Likewise.

> > > > 	* opts.c (common_handle_option): Likewise.

> > > > 	* toplev.c (general_init): Initialize

> > > > 	global_dc->use_nn_for_line_numbers_p.

> > > 

> > > Here's an alterative patch to the above that replaces the

> > > "-fdiagnostics-nn-line-numbers" option in earlier versions of the

> > > analyzer patch kit, by doing it at the DejaGnu level instead.

> > > 

> > > This patch adds support for obscuring the line numbers printed in

> > > the

> > > left-hand margin when printing the source code, converting them to

> > > NN,

> > > e.g from:

> > > 

> > >   7111 |   if (!(flags & 0x0001)) {

> > >        |      ^

> > >        |      |

> > >        |      (1) following 'true' branch...

> > >   7112 |

> > > 

> > > to:

> > > 

> > >    NN  |   if (!(flags & 0x0001)) {

> > >        |      ^

> > >        |      |

> > >        |      (1) following 'true' branch...

> > >    NN  |

> > > 

> > > This is useful in followup patches e.g. when testing how

> > > interprocedural

> > > paths are printed using multiline.exp, to avoid depending on

> > > precise line

> > > numbers.

> > > 

> > > I'm testing this now (but it seems to be a working, drop-in

> > > replacement

> > > for the option in the parts of the patch kit I've tested with it).

> > > 

> > > Examples of use can be seen in the analyzer test suite:

> > >   https://gcc.gnu.org/ml/gcc-patches/2020-01/msg00320.html

> > > (search for -fdiagnostics-nn-line-numbers and dg-begin-multiline-

> > > output

> > > there to get the idea)

> > > 

> > > OK for trunk assuming the other testing looks good?

> > > 

> > > gcc/testsuite/ChangeLog:

> > > 	* lib/gcc-dg.exp (cleanup-after-saved-dg-test): Reset global

> > > 	nn_line_numbers_enabled.

> > > 	* lib/nn-line-numbers.exp: New file.

> > > 	* lib/prune.exp: Load nn-line-numbers.exp.

> > > 	(prune_gcc_output): Call maybe-handle-nn-line-numbers.

> > OK

> > jeff

> 

> Thanks.  It turned out that the above patch didn't work; as noted in:

>   [PATCH] testsuite: add dg-enable-nn-line-numbers (v6)

>     https://gcc.gnu.org/ml/gcc-patches/2020-01/msg00517.html

> it turns out that the non-gcc parts of the testsuite that use prune.exp

> need to jump through some hoops due to Tcl lib path issues needing to

> preload libs by hacking in calls to load_gcc_lib, and at least one

> (libgo.exp) is a mirrored copy that we're not the canonical copy of.

> 

> Given that this is meant to be used in conjunction with multiline.exp

> the simplest fix was to move the code into multiline.exp, which I did

> in the latter patch.

> 

> Presumably that latter version is also OK?  (it has the advantage of

> actually successfully running...)

Yea, that's fine.
jeff
>

Patch

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index e6875de23831..cccd3ce4742c 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -940,6 +940,7 @@  if { [info procs saved-dg-test] == [list] } {
 	global set_compiler_env_var
 	global saved_compiler_env_var
 	global keep_saved_temps_suffixes
+	global nn_line_numbers_enabled
 	global multiline_expected_outputs
 	global freeform_regexps
 	global save_linenr_varnames
@@ -967,6 +968,7 @@  if { [info procs saved-dg-test] == [list] } {
 	if [info exists testname_with_flags] {
 	    unset testname_with_flags
 	}
+	set nn_line_numbers_enabled 0
 	set multiline_expected_outputs []
 	set freeform_regexps []
 
diff --git a/gcc/testsuite/lib/nn-line-numbers.exp b/gcc/testsuite/lib/nn-line-numbers.exp
new file mode 100644
index 000000000000..fed1004eb8e7
--- /dev/null
+++ b/gcc/testsuite/lib/nn-line-numbers.exp
@@ -0,0 +1,103 @@ 
+#   Copyright (C) 2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Support for obsuring the line numbers printed in the left-hand margin
+# when printing the source code, converting them to NN, e.g from:
+#
+#   7111 |   if (!(flags & 0x0001)) {
+#        |      ^
+#        |      |
+#        |      (1) following 'true' branch...
+#   7112 | 
+#
+# to:
+#
+#    NN  |   if (!(flags & 0x0001)) {
+#        |      ^
+#        |      |
+#        |      (1) following 'true' branch...
+#    NN  | 
+#
+# This is useful e.g. when testing how interprocedural paths are printed
+# using multiline.exp (to avoid depending on precise line numbers).
+
+############################################################################
+# Global variables.
+############################################################################
+
+# Was dg-enable-nn-line-numbers called?
+set nn_line_numbers_enabled 0
+
+############################################################################
+# Exported functions.
+############################################################################
+
+# Directive for enabling obscuring source-margin line numbers in "NN" form.
+
+proc dg-enable-nn-line-numbers { args } {
+    verbose "dg-nn-line-numbers: args: $args" 2
+    global nn_line_numbers_enabled
+    set nn_line_numbers_enabled 1
+}
+
+# Hook to be called by prune.exp's prune_gcc_output to convert such line
+# numbers to "NN" form.
+#
+# Match lines that start like:
+#  "   25 |"
+# and convert them to:
+#  "   NN |"
+#
+# It returns a copy of its input, with the above changes.
+
+proc maybe-handle-nn-line-numbers { text } {
+    global testname_with_flags
+
+    verbose "maybe-handle-nn-line-numbers" 3
+
+    global nn_line_numbers_enabled
+    if { [expr {!$nn_line_numbers_enabled}] } {
+	verbose "nn_line_numbers_enabled false; bailing out" 3
+	return $text
+    }
+    
+    verbose "maybe-handle-nn-line-numbers: text before: ${text}" 4
+
+    # dg.exp's dg-test trims leading whitespace from the output
+    # in this line:
+    #   set comp_output [string trimleft $comp_output]
+    # so we can't rely on the exact leading whitespace for the
+    # first line in the output.
+    # Match initial input lines that start like:
+    #  "25 |"
+    # and convert them to:
+    #  "   NN |"
+    set rexp2 {(^[0-9]+ \|)}
+    set count_a [regsub -all $rexp2 $text "   NN |" text]
+    verbose "maybe-handle-nn-line-numbers: count_a: $count_a" 4
+    
+    # Match lines that start like:
+    #  "   25 |"
+    # and convert them to:
+    #  "   NN |"
+    set rexp {([ ]+[0-9]+ \|)}
+    set count_b [regsub -all $rexp $text "   NN |" text]
+    verbose "maybe-handle-nn-line-numbers: count_b: $count_b" 4
+
+    verbose "maybe-handle-nn-line-numbers: text after: ${text}" 4
+
+    return $text
+}
diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index 6e2e84ba171c..daa8a4c6db7e 100644
--- a/gcc/testsuite/lib/prune.exp
+++ b/gcc/testsuite/lib/prune.exp
@@ -17,6 +17,7 @@ 
 # Prune messages from gcc that aren't useful.
 
 load_lib multiline.exp
+load_lib nn-line-numbers.exp
 
 if ![info exists TEST_ALWAYS_FLAGS] {
     set TEST_ALWAYS_FLAGS ""
@@ -74,6 +75,10 @@  proc prune_gcc_output { text } {
     # Ignore harmless warnings from Xcode 4.0.
     regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact unwind for\[^\n\]*" $text "" text
 
+    # If dg-enable-nn-line-numbers was provided, then obscure source-margin
+    # line numbers by converting them to "NN" form.
+    set text [maybe-handle-nn-line-numbers $text]
+    
     # Call into multiline.exp to handle any multiline output directives.
     set text [handle-multiline-outputs $text]