Hi! On 2017-05-22T18:55:29+0200, Tom de Vries <tom_devr...@mentor.com> wrote: > On 05/16/2017 03:12 PM, Rainer Orth wrote: >> [...], but the new proc ['dg-line'] needs documenting in sourcebuild.texi. > > Attached patch adds the missing documentation.
OK to expand that with the attached patch to "Document that 'linenumvar' in 'dg-line' may contain Tcl syntax"? (Hooray for embedded Tcl! -- Don't hurt me; I (later) have a use case where this does make things easier.) '{ dg-line LINENUMVAR }' This DejaGnu directive sets the variable LINENUMVAR to the line number of the source line. The variable LINENUMVAR, which must be unique per testcase, may then be used in subsequent 'dg-error', 'dg-warning', 'dg-message' and 'dg-bogus' directives. For example: int a; /* { dg-line first_def_a } */ float a; /* { dg-error "conflicting types of" } */ /* { dg-message "previous declaration of" "" { target *-*-* } first_def_a } */ Note that LINENUMVAR may contain Tcl syntax, for example: #pragma acc parallel loop [...] /* { dg-line line[incr line_count] } */ /* { dg-message "note: [...]" "" { target *-*-* } line$line_count } */ /* { dg-message "optimized: [...]" "" { target *-*-* } line$line_count } */ for (int j = 0; j < nj; ++j) { #pragma acc loop [...] /* { dg-line line[incr line_count] } */ /* { dg-message "missed: [...]" "" { target *-*-* } line$line_count } */ /* { dg-message "optimized: [...]" "" { target *-*-* } line$line_count } */ /* { dg-message "note: [...]" "" { target *-*-* } line$line_count } */ for (int i = 0; i < ni; ++i) For each 'dg-line', this increments a counter variable 'line_count' to construct unique 'line$line_count' names for LINENUMVAR: 'line1', 'line2', .... The preceding 'dg-line' may then be referred to via 'line$line_count'. Grüße Thomas ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
>From 2211acd9a902a5cab874762166dbca116a98bea5 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tho...@codesourcery.com> Date: Thu, 29 Oct 2020 07:04:54 +0100 Subject: [PATCH] Document that 'linenumvar' in 'dg-line' may contain Tcl syntax gcc/ * doc/sourcebuild.texi (dg-line): Document that 'linenumvar' may contain Tcl syntax. --- gcc/doc/sourcebuild.texi | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 49316a5d0ff9..92e9f4353d3f 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -1226,7 +1226,9 @@ targets. @item @{ dg-line @var{linenumvar} @} This DejaGnu directive sets the variable @var{linenumvar} to the line number of -the source line. The variable @var{linenumvar} can then be used in subsequent +the source line. +The variable @var{linenumvar}, which must be unique per testcase, may +then be used in subsequent @code{dg-error}, @code{dg-warning}, @code{dg-message} and @code{dg-bogus} directives. For example: @@ -1236,6 +1238,27 @@ float a; /* @{ dg-error "conflicting types of" @} */ /* @{ dg-message "previous declaration of" "" @{ target *-*-* @} first_def_a @} */ @end smallexample +Note that @var{linenumvar} may contain Tcl syntax, for example: + +@smallexample +#pragma acc parallel loop [...] /* @{ dg-line line[incr line_count] @} */ + /* @{ dg-message "note: [...]" "" @{ target *-*-* @} line$line_count @} */ + /* @{ dg-message "optimized: [...]" "" @{ target *-*-* @} line$line_count @} */ + for (int j = 0; j < nj; ++j) + @{ + #pragma acc loop [...] /* @{ dg-line line[incr line_count] @} */ + /* @{ dg-message "missed: [...]" "" @{ target *-*-* @} line$line_count @} */ + /* @{ dg-message "optimized: [...]" "" @{ target *-*-* @} line$line_count @} */ + /* @{ dg-message "note: [...]" "" @{ target *-*-* @} line$line_count @} */ + for (int i = 0; i < ni; ++i) +@end smallexample + +For each @code{dg-line}, this increments a counter variable +@code{line_count} to construct unique @code{line$line_count} names for +@var{linenumvar}: @code{line1}, @code{line2}, @dots{}. +The preceding @code{dg-line} may then be referred to via +@code{line$line_count}. + @item @{ dg-excess-errors @var{comment} [@{ target/xfail @var{selector} @}] @} This DejaGnu directive indicates that the test is expected to fail due to compiler messages that are not handled by @samp{dg-error}, -- 2.17.1