[RFC, testsuite] Add dg-save-linenr

Tom de Vries Tom_deVries@mentor.com
Mon May 22 17:10:00 GMT 2017


On 05/16/2017 03:12 PM, Rainer Orth wrote:
> Hi Tom,
> 
> sorry for chiming in so very late: I've been on vacation and sick in
> between...
> 

thanks for review anyway.

>> On 04/24/2017 05:20 PM, David Malcolm wrote:
>>> 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)
>>
>> Done.
> 
> I'd have preferred dg-linenum: it clarifiers that it's a number and we
> have precedent in DejaGnu's dg-linenum-format and dg-format-linenum...
> 

I see. I'll leave it dg-line for now, but I'll mention the dg-linenum 
variant upstream.

>>>> - error message formulation
>>>
>>> Nit: the new function should have a leading comment, explaining the
>>> usage.
>>>
>>
>> Done.
> 
> Not only that, but the new proc needs documenting in sourcebuild.texi.

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?

> (It's already way too hard for testsuite writers to find their way with
> the documentation; if parts are missing, it gets next to impossible.)
> 

Ack. I think the relative line numbers are also not documented.

> Besides, it may be worthwhile contributing/suggesting this upstream.

Will do.

Thanks,
- Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Document-dg-line-directive.patch
Type: text/x-patch
Size: 1287 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20170522/676418d4/attachment.bin>


More information about the Gcc-patches mailing list