On Sat, 2017-04-22 at 19:49 +0200, Tom de Vries wrote: > Hi, > > there are currently two types of line number supported in > dg-{error,warning,message,bogus} directives: absolute and relative. > With an absolute line number, it's immediately clear what line number > is > meant, but when a line is added at the start of the file, the line > number needs to be updated. With a relative line number, that > problem > is solved, but when relative line numbers become large, it becomes > less > clear what line it refers to, and when adding a line inbetween the > directive using the relative line number and the line it refers to, > the > relative line number still needs to be updated. > > This patch adds a directive dg-save-linenr with argument varname, > that > saves the line number of the directive in a variable varname, which > can > be used as line number in dg directives. > > Testing status: > - tested updated test-case objc.dg/try-catch-12.m > - ran tree-ssa.exp > > RFC: > - good idea?
Excellent idea; thanks! There are various places where I'd find this useful. > - naming of directive dg-save-linenr (dg-linenr, dg-save-line-nr, > dg-save-lineno, dg-save-line-number, etc) How about just "dg-line"? (if it's not already taken) or "dg-name-line" / "dg-named-line" ? in that the directive is effectively giving the line a name, giving: [...] extern void some_func (int *); /* { dg-line some_func_decl } */ [...] /* { dg-message "but argument is of type" "" { target *-*-* } some_func_decl } */ > - allowed variable names (currently: start with letter, followed by > alphanumerical or underscore) Seems reasonable; lack of leading digit allows it to be distinguished from absolute and relative numbers. > - should we use a prefix symbol or some such when the variable is > used > (and possibly defined as well)? F.i.: > /* { dg-save-linenr %some_func_decl } *./ > /* { dg-message "but argument is of type" "" { target *-*-* } > %some_func_decl } */ These are sometimes called "sigils". I'd prefer not. > - error message formulation Nit: the new function should have a leading comment, explaining the usage. Thanks again Dave