From patchwork Thu Apr 27 11:16:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 88201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp190576vqo; Thu, 27 Apr 2023 04:17:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7pBA0iyC21ycTIdhT4usDO+K6OlQeSSU7COukbw31Rqwft2GCxVty87o4DcQNi7hLkJUy7 X-Received: by 2002:a17:906:fd82:b0:94f:3980:bf87 with SMTP id xa2-20020a170906fd8200b0094f3980bf87mr1430233ejb.43.1682594241219; Thu, 27 Apr 2023 04:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682594241; cv=none; d=google.com; s=arc-20160816; b=LDZF0DVBVEPJOqKr014qZovmkVYPI6G8phTz5Zy1iSictDtuo5gfZEt5oTRrZQS8N7 laCgwIpZ/uQNFy8zzg03iGRuARH+wetBB15pK3nsiWIu4pcuCfahSDCici+cXlaa83Vc mpWmmLvmYDpJh4OYX54CbasunjRL9bJCBH97o+aKgtX6ZXmG7uKn3sj8qu6CFhS+5w/b mdvaIWsMb7ga5ULVazTFH6p8fNlUnQt5C8r6hSlws7prI2wffzU6Yo+fHdkejbApoX8T 49Jd38pT3XlRtZJz3iPBDYUBSdvL6PwN5T4GC2LZCWMI5FOuIIuDa5eEHf8VlLDQUNiL 0aTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=3D/hYRhp8Otpi6hVzZCAWMy7+urRziks6np1p80pOa4=; b=XJqQjVGVt9bdA5ENrIwO6WS8kEw4ozayYjtvoDej63AwB+PNMyliTfJvWaPo/DPsqD FBjDfpWW9BueRu6pEfVL57VTZ8SZR3muthOrPu8pgJFoHRcKiX3P3Xap0GKrdcdL/bEP HyujaFGiVa2UhRfTTrvO0/WPSuol8cfCMWjGtzQCagDw0eihvcJDg4XCuvTMdE72KuRW kElmLApGtpcZ8u5EcnHvBQRAVecO+rbR/91NDxVTinccCRVT9Cm7e8vARPkuXUmhoGUg a1WWdAE5KRh3jSTiLd94p4dgL6G9hMEdP4L/6v1iCWQ+W7Q7R+0f8xoSxQPMt0RtaFy2 vEqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WC7YOjP3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e17-20020a1709062c1100b0094f5aee710esi12380638ejh.102.2023.04.27.04.17.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 04:17:21 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WC7YOjP3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 244DD3858D38 for ; Thu, 27 Apr 2023 11:17:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 244DD3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682594240; bh=3D/hYRhp8Otpi6hVzZCAWMy7+urRziks6np1p80pOa4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=WC7YOjP3vksqy5yLAJ4T4LSd3gXtGb2PvyeeBW2hPNMH8R91KM527xPfpW/f/+yzw tBDA8kWdTsGOmmISQsr5peop6JdZScvbFnXgdBL/pmzEGHZX6QHv+62kglGMAAXMVs lfrURM6kuPNuCA4AOOpdZw7/PYchdAh5sM9jMGfo= 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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 620A63858D33 for ; Thu, 27 Apr 2023 11:16:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 620A63858D33 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-dDiRwWslO2eJ1Q0kVbVO8Q-1; Thu, 27 Apr 2023 07:16:35 -0400 X-MC-Unique: dDiRwWslO2eJ1Q0kVbVO8Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5CFBB101A550 for ; Thu, 27 Apr 2023 11:16:35 +0000 (UTC) Received: from localhost (unknown [10.42.28.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2872BC15BA0 for ; Thu, 27 Apr 2023 11:16:35 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] doc: Describe behaviour of enums with fixed underlying type Date: Thu, 27 Apr 2023 12:16:34 +0100 Message-Id: <20230427111634.1728893-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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 Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764327939410754168?= X-GMAIL-MSGID: =?utf-8?q?1764327939410754168?= C2x adds the ability to give an enumeration type a fixed underlying type, as C++ already has. The -fshort-enums option alters the compiler's choice of underlying type, but when it's fixed the compiler can't choose. Similarly for C++ -fstrict-enums has no effect with a fixed underlying type, because every value of the underlying type is a valid value of the enumeration type. This caused confusion recently: https://gcc.gnu.org/PR109532 OK for trunk? -- >8 -- gcc/ChangeLog: * doc/invoke.texi (Code Gen Options): Note that -fshort-enums is ignored for a fixed underlying type. (C++ Dialect Options): Likewise for -fstrict-enums. --- gcc/doc/invoke.texi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 2f40c58b21c..0f91464f8c0 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -3495,6 +3495,8 @@ defined in the C++ standard; basically, a value that can be represented in the minimum number of bits needed to represent all the enumerators). This assumption may not be valid if the program uses a cast to convert an arbitrary integer value to the enumerated type. +This option has no effect for an enumeration type with a fixed underlying +type. @opindex fstrong-eval-order @item -fstrong-eval-order @@ -18303,6 +18305,8 @@ Use it to conform to a non-default application binary interface. Allocate to an @code{enum} type only as many bytes as it needs for the declared range of possible values. Specifically, the @code{enum} type is equivalent to the smallest integer type that has enough room. +This option has no effect for an enumeration type with a fixed underlying +type. @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate code that is not binary compatible with code generated without that switch.