public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v2]: gcc/doc/extend.texi: Update builtin example for __builtin_FILE, __builtin_LINE __builtin_FUNCTION
@ 2024-01-10 21:28 Jonny Grant
  2024-01-14  5:34 ` Sandra Loosemore
  0 siblings, 1 reply; 3+ messages in thread
From: Jonny Grant @ 2024-01-10 21:28 UTC (permalink / raw)
  To: gcc-patches


2024-01-10  Jonathan Grant  <jg@jguk.org>
gcc/ChangeLog:
	* doc/extend.texi: Update builtin example for __builtin_FILE
 __builtin_LINE __builtin_FUNCTION.



>From 66290eb477dd1a99310ad9972c45391c2a87c1c7 Mon Sep 17 00:00:00 2001
From: Jonathan Grant <jg@jguk.org>
Date: Wed, 29 Nov 2023 11:02:06 +0000
Subject: [PATCH] gcc/doc: Update builtin example for __builtin_FILE
 __builtin_LINE __builtin_FUNCTION


Signed-off-by: Jonathan Grant <jg@jguk.org>
---
 gcc/doc/extend.texi | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 1ae589aeb29..f17a4b215de 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -14660,20 +14660,22 @@ to @var{F} or the empty string if the call was not made at function
 scope.
 
 For example, in the following, each call to function @code{foo} will
-print a line similar to @code{"file.c:123: foo: message"} with the name
+print a line similar to @code{"file.c:5: foo: message"} with the name
 of the file and the line number of the @code{printf} call, the name of
 the function @code{foo}, followed by the word @code{message}.
 
 @smallexample
-const char*
-function (const char *func = __builtin_FUNCTION ())
+#include <stdio.h>
+
+void foo (void)
 @{
-  return func;
+  printf ("%s:%i: %s: message\n", __builtin_FILE (), __builtin_LINE (), __builtin_FUNCTION ());
+  printf ("%s:%i: %s: message\n", __builtin_FILE (), __builtin_LINE (), __builtin_FUNCTION ());
 @}
 
-void foo (void)
+int main (void)
 @{
-  printf ("%s:%i: %s: message\n", file (), line (), function ());
+  foo();
 @}
 @end smallexample
 
-- 
2.40.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2]: gcc/doc/extend.texi: Update builtin example for __builtin_FILE, __builtin_LINE __builtin_FUNCTION
  2024-01-10 21:28 [PATCH v2]: gcc/doc/extend.texi: Update builtin example for __builtin_FILE, __builtin_LINE __builtin_FUNCTION Jonny Grant
@ 2024-01-14  5:34 ` Sandra Loosemore
  2024-02-07 14:56   ` Jonny Grant
  0 siblings, 1 reply; 3+ messages in thread
From: Sandra Loosemore @ 2024-01-14  5:34 UTC (permalink / raw)
  To: Jonny Grant, gcc-patches

On 1/10/24 14:28, Jonny Grant wrote:
 >
 > 2024-01-10  Jonathan Grant  <jg@jguk.org>
 > gcc/ChangeLog:
 > 	* doc/extend.texi: Update builtin example for __builtin_FILE
 >   __builtin_LINE __builtin_FUNCTION.
 >
 >
 >
 >>From 66290eb477dd1a99310ad9972c45391c2a87c1c7 Mon Sep 17 00:00:00 2001
 > From: Jonathan Grant <jg@jguk.org>
 > Date: Wed, 29 Nov 2023 11:02:06 +0000
 > Subject: [PATCH] gcc/doc: Update builtin example for __builtin_FILE
 >   __builtin_LINE __builtin_FUNCTION
 >
 >
 > Signed-off-by: Jonathan Grant <jg@jguk.org>
 > ---
 >   gcc/doc/extend.texi | 14 ++++++++------
 >   1 file changed, 8 insertions(+), 6 deletions(-)
 >
 > diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
 > index 1ae589aeb29..f17a4b215de 100644
 > --- a/gcc/doc/extend.texi
 > +++ b/gcc/doc/extend.texi
 > @@ -14660,20 +14660,22 @@ to @var{F} or the empty string if the call was not 
made at function
 >   scope.
 >
 >   For example, in the following, each call to function @code{foo} will
 > -print a line similar to @code{"file.c:123: foo: message"} with the name
 > +print a line similar to @code{"file.c:5: foo: message"} with the name

Please also s/will print/prints/

 >   of the file and the line number of the @code{printf} call, the name of
 >   the function @code{foo}, followed by the word @code{message}.
 >
 >   @smallexample
 > -const char*
 > -function (const char *func = __builtin_FUNCTION ())
 > +#include <stdio.h>
 > +
 > +void foo (void)
 >   @{
 > -  return func;
 > +  printf ("%s:%i: %s: message\n", __builtin_FILE (), __builtin_LINE (), 
__builtin_FUNCTION ());
 > +  printf ("%s:%i: %s: message\n", __builtin_FILE (), __builtin_LINE (), 
__builtin_FUNCTION ());

Is this duplicated code a mistake?  As you have it, each call to foo prints 
*two* lines, not "a line".  Maybe you mean to have more than one call to foo 
instead of more than one line printed per call?  If it's intentional, please 
correct the above descriptive text.

Also, I'm pretty sure this line of code is too long to format nicely in the PDF 
manual (it's well over 80 characters).  I'd put a line break after the call to 
__builtin_FILE ().

-Sandra



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2]: gcc/doc/extend.texi: Update builtin example for __builtin_FILE, __builtin_LINE __builtin_FUNCTION
  2024-01-14  5:34 ` Sandra Loosemore
@ 2024-02-07 14:56   ` Jonny Grant
  0 siblings, 0 replies; 3+ messages in thread
From: Jonny Grant @ 2024-02-07 14:56 UTC (permalink / raw)
  To: Sandra Loosemore, gcc-patches



On 14/01/2024 05:34, Sandra Loosemore wrote:
> On 1/10/24 14:28, Jonny Grant wrote:
>>
>> 2024-01-10  Jonathan Grant  <jg@jguk.org>
>> gcc/ChangeLog:
>>     * doc/extend.texi: Update builtin example for __builtin_FILE
>>   __builtin_LINE __builtin_FUNCTION.
>>
>>
>>
>>>From 66290eb477dd1a99310ad9972c45391c2a87c1c7 Mon Sep 17 00:00:00 2001
>> From: Jonathan Grant <jg@jguk.org>
>> Date: Wed, 29 Nov 2023 11:02:06 +0000
>> Subject: [PATCH] gcc/doc: Update builtin example for __builtin_FILE
>>   __builtin_LINE __builtin_FUNCTION
>>
>>
>> Signed-off-by: Jonathan Grant <jg@jguk.org>
>> ---
>>   gcc/doc/extend.texi | 14 ++++++++------
>>   1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
>> index 1ae589aeb29..f17a4b215de 100644
>> --- a/gcc/doc/extend.texi
>> +++ b/gcc/doc/extend.texi
>> @@ -14660,20 +14660,22 @@ to @var{F} or the empty string if the call was not made at function
>>   scope.
>>
>>   For example, in the following, each call to function @code{foo} will
>> -print a line similar to @code{"file.c:123: foo: message"} with the name
>> +print a line similar to @code{"file.c:5: foo: message"} with the name
> 
> Please also s/will print/prints/
> 
>>   of the file and the line number of the @code{printf} call, the name of
>>   the function @code{foo}, followed by the word @code{message}.
>>
>>   @smallexample
>> -const char*
>> -function (const char *func = __builtin_FUNCTION ())
>> +#include <stdio.h>
>> +
>> +void foo (void)
>>   @{
>> -  return func;
>> +  printf ("%s:%i: %s: message\n", __builtin_FILE (), __builtin_LINE (), __builtin_FUNCTION ());
>> +  printf ("%s:%i: %s: message\n", __builtin_FILE (), __builtin_LINE (), );
> 
> Is this duplicated code a mistake?  As you have it, each call to foo prints *two* lines, not "a line".  Maybe you mean to have more than one call to foo instead of more than one line printed per call?  If it's intentional, please correct the above descriptive text.

Thank you for the review comments Sandra.
The duplicate lines were my mistake. 

> Also, I'm pretty sure this line of code is too long to format nicely in the PDF manual (it's well over 80 characters).  I'd put a line break after the call to __builtin_FILE ().

yes, that's good. If the __builtin_LINE () is on the next line, unfortunately line number won't be the same as the printf line. But I did move the __builtin_FUNCTION () so it's under 80, is that okay?

Will a v3 version of the patch with a few other changes. Let me know what you think.

Thanks, Jonny

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-07 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 21:28 [PATCH v2]: gcc/doc/extend.texi: Update builtin example for __builtin_FILE, __builtin_LINE __builtin_FUNCTION Jonny Grant
2024-01-14  5:34 ` Sandra Loosemore
2024-02-07 14:56   ` Jonny Grant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).