public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] doc: Fix documentation around 'asm' keyword in C++
@ 2021-10-20 12:28 Jonathan Wakely
  2021-10-20 17:44 ` Jeff Law
  2021-10-20 23:29 ` Jason Merrill
  0 siblings, 2 replies; 4+ messages in thread
From: Jonathan Wakely @ 2021-10-20 12:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

The documentation on asm statements suggests asm is always a GNU
extension, but it's been part of ISO C++ since the first standard.

The documentation of -fno-asm is wrong for C++ as it states that it only
affects typeof, but actually it affects typeof and asm (despite asm
being part of ISO C++).

gcc/ChangeLog:

	* doc/extend.texi (Basic Asm): Clarify that asm is not an
	extension in C++.
	* doc/invoke.texi (-fno-asm): Fix description for C++.

OK for trunk?


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3050 bytes --]

commit 0321c56153d385fda25ada73ca4e474358d7ec9c
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Oct 20 12:46:29 2021

    doc: Fix documentation around 'asm' keyword in C++
    
    The documentation on asm statements suggests asm is always a GNU
    extension, but it's been part of ISO C++ since the first standard.
    
    The documentation of -fno-asm is wrong for C++ as it states that it only
    affects typeof, but actually it affects typeof and asm (despite asm
    being part of ISO C++).
    
    gcc/ChangeLog:
    
            * doc/extend.texi (Basic Asm): Clarify that asm is not an
            extension in C++.
            * doc/invoke.texi (-fno-asm): Fix description for C++.

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 3c942d81c32..62280f6e00b 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -9728,10 +9728,12 @@ A basic @code{asm} statement has the following syntax:
 asm @var{asm-qualifiers} ( @var{AssemblerInstructions} )
 @end example
 
-The @code{asm} keyword is a GNU extension.
-When writing code that can be compiled with @option{-ansi} and the
-various @option{-std} options, use @code{__asm__} instead of 
-@code{asm} (@pxref{Alternate Keywords}).
+For the C language, the @code{asm} keyword is a GNU extension.
+When writing C code that can be compiled with @option{-ansi} and the
+@option{-std} options that select a base standard, use @code{__asm__}
+instead of @code{asm} (@pxref{Alternate Keywords}).  For the C++
+language, @code{asm} is a standard keyword, but @code{__asm__} can
+be used for code compiled with @option{-fno-asm}.
 
 @subsubheading Qualifiers
 @table @code
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c93d822431f..6d1e328571a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2485,14 +2485,14 @@ supported for C as this construct is allowed by C++.
 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
 keyword, so that code can use these words as identifiers.  You can use
 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
-instead.  @option{-ansi} implies @option{-fno-asm}.
+instead.  In C, @option{-ansi} implies @option{-fno-asm}.
 
-In C++, this switch only affects the @code{typeof} keyword, since
-@code{asm} and @code{inline} are standard keywords.  You may want to
-use the @option{-fno-gnu-keywords} flag instead, which has the same
-effect.  In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this
-switch only affects the @code{asm} and @code{typeof} keywords, since
-@code{inline} is a standard keyword in ISO C99.
+In C++, @code{inline} is a standard keyword and is not affected by
+this switch.  You may want to use the @option{-fno-gnu-keywords} flag
+instead, which disables @code{typeof} but not @code{asm} and
+@code{inline}.  In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
+this switch only affects the @code{asm} and @code{typeof} keywords,
+since @code{inline} is a standard keyword in ISO C99.
 
 @item -fno-builtin
 @itemx -fno-builtin-@var{function}

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

* Re: [PATCH] doc: Fix documentation around 'asm' keyword in C++
  2021-10-20 12:28 [PATCH] doc: Fix documentation around 'asm' keyword in C++ Jonathan Wakely
@ 2021-10-20 17:44 ` Jeff Law
  2021-10-20 18:54   ` Jonathan Wakely
  2021-10-20 23:29 ` Jason Merrill
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff Law @ 2021-10-20 17:44 UTC (permalink / raw)
  To: Jonathan Wakely, gcc-patches; +Cc: Joseph Myers



On 10/20/2021 6:28 AM, Jonathan Wakely via Gcc-patches wrote:
> The documentation on asm statements suggests asm is always a GNU
> extension, but it's been part of ISO C++ since the first standard.
>
> The documentation of -fno-asm is wrong for C++ as it states that it only
> affects typeof, but actually it affects typeof and asm (despite asm
> being part of ISO C++).
>
> gcc/ChangeLog:
>
> 	* doc/extend.texi (Basic Asm): Clarify that asm is not an
> 	extension in C++.
> 	* doc/invoke.texi (-fno-asm): Fix description for C++.
>
> OK for trunk?
OK
jeff


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

* Re: [PATCH] doc: Fix documentation around 'asm' keyword in C++
  2021-10-20 17:44 ` Jeff Law
@ 2021-10-20 18:54   ` Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2021-10-20 18:54 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc Patches, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 1026 bytes --]

On Wed, 20 Oct 2021 at 18:44, Jeff Law wrote:
> On 10/20/2021 6:28 AM, Jonathan Wakely via Gcc-patches wrote:
> > The documentation on asm statements suggests asm is always a GNU
> > extension, but it's been part of ISO C++ since the first standard.
> >
> > The documentation of -fno-asm is wrong for C++ as it states that it only
> > affects typeof, but actually it affects typeof and asm (despite asm
> > being part of ISO C++).
> >
> > gcc/ChangeLog:
> >
> >       * doc/extend.texi (Basic Asm): Clarify that asm is not an
> >       extension in C++.
> >       * doc/invoke.texi (-fno-asm): Fix description for C++.
> >
> > OK for trunk?
> OK

On IRC Jakub and Segher suggested slightly different wording for the
Basic Asm section, to clarify what I was trying to say about -std=cNN
options. I pushed something based on Segher's suggestion ("-ansi and
the -std options that select C dialects without GNU extensions"). The
final version is attached to this mail, I hope it was OK to tweak it
without getting approval again.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3068 bytes --]

commit 154c6d430ee173904237de64d5aae11565201318
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Oct 20 19:41:49 2021

    doc: Fix documentation around 'asm' keyword in C++
    
    The documentation on asm statements suggests asm is always a GNU
    extension, but it's been part of ISO C++ since the first standard.
    
    The documentation of -fno-asm is wrong for C++ as it states that it only
    affects typeof, but actually it affects typeof and asm (despite asm
    being part of ISO C++).
    
    gcc/ChangeLog:
    
            * doc/extend.texi (Basic Asm): Clarify that asm is not an
            extension in C++.
            * doc/invoke.texi (-fno-asm): Fix description for C++.

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 3c942d81c32..eee4c6737bb 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -9728,10 +9728,12 @@ A basic @code{asm} statement has the following syntax:
 asm @var{asm-qualifiers} ( @var{AssemblerInstructions} )
 @end example
 
-The @code{asm} keyword is a GNU extension.
-When writing code that can be compiled with @option{-ansi} and the
-various @option{-std} options, use @code{__asm__} instead of 
-@code{asm} (@pxref{Alternate Keywords}).
+For the C language, the @code{asm} keyword is a GNU extension.
+When writing C code that can be compiled with @option{-ansi} and the
+@option{-std} options that select C dialects without GNU extensions, use
+@code{__asm__} instead of @code{asm} (@pxref{Alternate Keywords}).  For
+the C++ language, @code{asm} is a standard keyword, but @code{__asm__}
+can be used for code compiled with @option{-fno-asm}.
 
 @subsubheading Qualifiers
 @table @code
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c93d822431f..6d1e328571a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2485,14 +2485,14 @@ supported for C as this construct is allowed by C++.
 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
 keyword, so that code can use these words as identifiers.  You can use
 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
-instead.  @option{-ansi} implies @option{-fno-asm}.
+instead.  In C, @option{-ansi} implies @option{-fno-asm}.
 
-In C++, this switch only affects the @code{typeof} keyword, since
-@code{asm} and @code{inline} are standard keywords.  You may want to
-use the @option{-fno-gnu-keywords} flag instead, which has the same
-effect.  In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this
-switch only affects the @code{asm} and @code{typeof} keywords, since
-@code{inline} is a standard keyword in ISO C99.
+In C++, @code{inline} is a standard keyword and is not affected by
+this switch.  You may want to use the @option{-fno-gnu-keywords} flag
+instead, which disables @code{typeof} but not @code{asm} and
+@code{inline}.  In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
+this switch only affects the @code{asm} and @code{typeof} keywords,
+since @code{inline} is a standard keyword in ISO C99.
 
 @item -fno-builtin
 @itemx -fno-builtin-@var{function}

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

* Re: [PATCH] doc: Fix documentation around 'asm' keyword in C++
  2021-10-20 12:28 [PATCH] doc: Fix documentation around 'asm' keyword in C++ Jonathan Wakely
  2021-10-20 17:44 ` Jeff Law
@ 2021-10-20 23:29 ` Jason Merrill
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2021-10-20 23:29 UTC (permalink / raw)
  To: Jonathan Wakely, gcc-patches; +Cc: Joseph Myers

On 10/20/21 08:28, Jonathan Wakely wrote:
> The documentation on asm statements suggests asm is always a GNU
> extension, but it's been part of ISO C++ since the first standard.
> 
> The documentation of -fno-asm is wrong for C++ as it states that it only
> affects typeof, but actually it affects typeof and asm (despite asm
> being part of ISO C++).
> 
> gcc/ChangeLog:
> 
> 	* doc/extend.texi (Basic Asm): Clarify that asm is not an
> 	extension in C++.
> 	* doc/invoke.texi (-fno-asm): Fix description for C++.
> 
> OK for trunk?

OK, thanks.

Jason



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

end of thread, other threads:[~2021-10-20 23:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20 12:28 [PATCH] doc: Fix documentation around 'asm' keyword in C++ Jonathan Wakely
2021-10-20 17:44 ` Jeff Law
2021-10-20 18:54   ` Jonathan Wakely
2021-10-20 23:29 ` Jason Merrill

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).