From patchwork Wed Oct 20 12:28:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 46434 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0FD7F3858437 for ; Wed, 20 Oct 2021 12:29:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FD7F3858437 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634732943; bh=zsRFVwfv/qRT3TIIS+/P4Iq8obk6Cz++DcUPN15gMmA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CYCat13HA+oUlL8XDJ7hNNOF1ecVX6/5QPnonCXaDAsMGBMZLIVlp+6WjvJ4bt/V4 iB2G9qTbTuqFrIXxbZy5qQCsUdCEJ5EtY8OJGjsSsVgUeIi1RqWN86wLWpwOqlLz3C wN8zfqP3Zjh+uWVDhQ8ImlKWowxPhYU9ixOumLGk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id E9BF33858419 for ; Wed, 20 Oct 2021 12:28:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E9BF33858419 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-359-LpB1sjo4Oo6KyAkUo28rwg-1; Wed, 20 Oct 2021 08:28:31 -0400 X-MC-Unique: LpB1sjo4Oo6KyAkUo28rwg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA8541882FA3; Wed, 20 Oct 2021 12:28:29 +0000 (UTC) Received: from localhost (unknown [10.33.36.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 207275DD68; Wed, 20 Oct 2021 12:28:28 +0000 (UTC) Date: Wed, 20 Oct 2021 13:28:28 +0100 To: gcc-patches@gcc.gnu.org Subject: [PATCH] doc: Fix documentation around 'asm' keyword in C++ Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Cc: Joseph Myers Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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? commit 0321c56153d385fda25ada73ca4e474358d7ec9c Author: Jonathan Wakely 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}