Message ID | 9feb5b24-5ba2-4316-c8d1-012d5a297029@mentor.com |
---|---|
State | New |
Headers | show |
On 05/22/2017 06:55 PM, Tom de Vries wrote: >> Besides, it may be worthwhile contributing/suggesting this upstream. > > Will do. Sent 'relative line numbers and dg-line directive' to dejagnu ml ( http://lists.gnu.org/archive/html/dejagnu/2017-05/msg00000.html ). Thanks, - Tom
On May 22, 2017, at 9:55 AM, Tom de Vries <Tom_deVries@mentor.com> wrote: > > Attached patch adds the missing documentation. > > It looks like this in gccint.info: > ... > '{ dg-line LINENUMVAR }' > This DejaGnu directive sets the variable LINENUMVAR to the line > number of the source line. The variable LINENUMVAR can 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: AFAIK, dg-line does not work in the gnat testsuite. This is similar to PR80219 for relative line numbers. I'm not sure if we should mention this here, or how. > > OK for trunk like this? Ok.
Hi! On 2017-05-22T18:55:29+0200, Tom de Vries <Tom_deVries@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
On Fri, Oct 30, 2020 at 12:34:57PM +0100, Thomas Schwinge wrote: > Hi! > > On 2017-05-22T18:55:29+0200, Tom de Vries <Tom_deVries@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.) Is it desirable though? I mean if we ever decide to switch from dejagnu to something else, adding parsing of our dg-* grammar is not that hard, and while we rely on some tcl details already (e.g. the {}s vs. ""s for regular expressions etc.), allowing arbitrary embedded tcl will make that effort even harder. Jakub
Hi Jakub! On 2020-10-30T12:40:02+0100, Jakub Jelinek <jakub@redhat.com> wrote: > On Fri, Oct 30, 2020 at 12:34:57PM +0100, Thomas Schwinge wrote: >> On 2017-05-22T18:55:29+0200, Tom de Vries <Tom_deVries@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.) > > Is it desirable though? I hear you. > I mean if we ever decide to switch from dejagnu to something else, > adding parsing of our dg-* grammar is not that hard, and while we rely > on some tcl details already (e.g. the {}s vs. ""s for regular expressions > etc.), allowing arbitrary embedded tcl will make that effort even harder. (It's not much, but note that there already are some more "arbitrary" Tcl-y idioms in the testsuite.) I had considered the point you're making, but it's already many years (decades?) that we (meaning: some?) would like to switch away from DejaGnu (to what else -- QMTest apparently isn't it?) -- so, this isn't going to happen next week. If we then ever port to something else, I'm sure the new system will be likewise expressive/extensible. Thus I decided to use the convenience now, and defer the potential (minor, compared to the overall effort) complication until then. 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
On 10/30/20 5:34 AM, Thomas Schwinge wrote: > Hi! > > On 2017-05-22T18:55:29+0200, Tom de Vries <Tom_deVries@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 > > 0001-Document-that-linenumvar-in-dg-line-may-contain-Tcl-.patch > > From 2211acd9a902a5cab874762166dbca116a98bea5 Mon Sep 17 00:00:00 2001 > From: Thomas Schwinge <thomas@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. OK jeff
Document dg-line directive 2017-05-22 Tom de Vries <tom@codesourcery.com> * doc/sourcebuild.texi: Document dg-line directive. --- gcc/doc/sourcebuild.texi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 84d9a22..a887337 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -1180,6 +1180,18 @@ associated with the bogus message. It is usually used with @samp{xfail} to indicate that the message is a known problem for a particular set of 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 +@code{dg-error}, @code{dg-warning}, @code{dg-message} and @code{dg-bogus} +directives. For example: + +@smallexample +int a; /* @{ dg-line first_def_a @} */ +float a; /* @{ dg-error "conflicting types of" @} */ +/* @{ dg-message "previous declaration of" "" @{ target *-*-* @} first_def_a @} */ +@end smallexample + @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},