[v2] : gcc/doc/extend.texi: Update builtin example for __builtin_FILE, __builtin_LINE __builtin_FUNCTION

Message ID 74e2f370-c3ec-4bdb-a9a5-fe037797a7d1@jguk.org
State New
Headers
Series [v2] : gcc/doc/extend.texi: Update builtin example for __builtin_FILE, __builtin_LINE __builtin_FUNCTION |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Testing passed

Commit Message

Jonny Grant Jan. 10, 2024, 9:28 p.m. UTC
  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(-)
  

Comments

Sandra Loosemore Jan. 14, 2024, 5:34 a.m. UTC | #1
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
  
Jonny Grant Feb. 7, 2024, 2:56 p.m. UTC | #2
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
  

Patch

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