From patchwork Fri Nov 11 15:37:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 693768 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tFkcM2Y6rz9t0q for ; Sat, 12 Nov 2016 02:39:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="LLop53HP"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=yI7/7Anqv6akIaQl Y7nKxlefrJgR5FqVzteI+o/RYAg6I8y3Aacw1AjcWgZzvzQpDG4wqc3zOGVTV/LE JIcjbMnxXySEcc0XdeZ+zMhNtRiZ29ZyUpbmx6YJAGvceljadPS+OgjNzF5wTxbX gT99gQNCWUIO2IKsE1yL8plei30= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=hDLQf+L1qxOFCK+eaMtOYO I7tS8=; b=LLop53HPZqhtjDMCFb9iiaFE8U+aTdIYgIu7p1sxLjRV4wcADlMPwL bCKhe8ZldoDPEDEvuAAVcpazPjTnlwCGkDe+VuV9E2qxNs1AqkuQ1MLRjXLiPdTw S2wpKCU8AUO/Wxb3rnYFaAMFlfTCYsToTCvUYakbVvPlodUsDlqlY= Received: (qmail 76896 invoked by alias); 11 Nov 2016 15:38:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 76794 invoked by uid 89); 11 Nov 2016 15:38:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=char**, 7886 X-HELO: EUR02-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr10072.outbound.protection.outlook.com (HELO EUR02-HE1-obe.outbound.protection.outlook.com) (40.107.1.72) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Nov 2016 15:38:28 +0000 Received: from DB5PR08CA0021.eurprd08.prod.outlook.com (10.163.102.159) by VI1PR0801MB1790.eurprd08.prod.outlook.com (10.168.67.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.6; Fri, 11 Nov 2016 15:38:25 +0000 Received: from DB3FFO11FD010.protection.gbl (2a01:111:f400:7e04::183) by DB5PR08CA0021.outlook.office365.com (2a01:111:e400:52c3::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.721.10 via Frontend Transport; Fri, 11 Nov 2016 15:38:24 +0000 Authentication-Results: spf=pass (sender IP is 217.140.96.140) smtp.mailfrom=arm.com; codesourcery.com; dkim=none (message not signed) header.d=none; codesourcery.com; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 217.140.96.140 as permitted sender) receiver=protection.outlook.com; client-ip=217.140.96.140; helo=nebula.arm.com; Received: from nebula.arm.com (217.140.96.140) by DB3FFO11FD010.mail.protection.outlook.com (10.47.216.166) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.707.3 via Frontend Transport; Fri, 11 Nov 2016 15:38:24 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:884; Count:13 Received: from e107456-lin.cambridge.arm.com (10.1.2.79) by mail.arm.com (10.1.105.66) with Microsoft SMTP Server id 14.3.294.0; Fri, 11 Nov 2016 15:38:01 +0000 From: James Greenhalgh To: CC: , , Subject: [Patch 5/17] Add -fpermitted-flt-eval-methods=[c11|ts-18661-3] Date: Fri, 11 Nov 2016 15:37:22 +0000 Message-ID: <1478878647-22547-6-git-send-email-james.greenhalgh@arm.com> In-Reply-To: <1478878647-22547-1-git-send-email-james.greenhalgh@arm.com> References: <1475254617-10825-1-git-send-email-james.greenhalgh@arm.com> <1478878647-22547-1-git-send-email-james.greenhalgh@arm.com> MIME-Version: 1.0 X-IncomingHeaderCount: 13 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:CAL; SCL:-1; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(199003)(189002)(377424004)(50986999)(512874002)(246002)(104016004)(6916009)(8676002)(110136003)(2950100002)(356003)(6666003)(5890100001)(4610100001)(7846002)(626004)(5660300001)(305945005)(568964002)(50226002)(8936002)(230783001)(84326002)(2906002)(4326007)(87936001)(189998001)(106466001)(33646002)(77096005)(26826002)(2351001)(2476003)(92566002)(586003)(86362001)(76176999)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0801MB1790; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD010; 1:eP9XbhV0Acyb69RleJQyGPzuRm1reXl37KJ1KgTmtYWLrM9JZfm6VPrsVTIathbOtBFUs1QiPu1aKPOLxqGGwgogiwtjjjUVkePFtdPZ2z25wgM723hb1icAO2wR9HcypuHl61zQbPj4ldIeqcTXOF3nvt62Ir4EawzGTEiekdKtZBONWFEYsndYtCKVnN+dRB/11eKL1b0R5Cygzv4MTG0z6AGNqggm7YTO5qM7yYSdyGEQ/EXhyUfGoc9OK3VzMmny6jaM/PhNuxL9pi5O0XR935qK4ZReP+fqBGutll6ujgnWibT14e1CJUTxHzvvUou9TRvlDsQLmyF0jyKxeqS7413smghVsyvNxVPNGgO2Xj0wDEahiyuU1l+sm8oyos2yJJx2VLIpGAJ/62T6ktcDF9XMYREMdA1/UXFY89dW02wrEux4tKH+2ZYWDqoIEQAkp5r0kGm73esvUUHO8gxY3Jo4/hFbLofH2/Iqu/0ENA5QYqFBlnWLmdInmKGskfHL1M1Cu4Oh65OPUbSPbU9cFVxWOTtcn1QcNoHhB5+NXESSO8YrpmANbTXrnd4yl5Cju5+HA4zeXZM/gcTqSCjJBmHXWcMyT13O92JB3zg= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1790; 2:RXhNHVK2JCVTOhpB50mBtaDLrjuv3ZjxDdUXguZMKwcrddn51pfh8Bh/Hms4/+8U67do1tkn02fG1Yx+XkrwdvxpWeJ20qPeOunsMBs45sOjUFPXePt7qlWXKtykySP0rJpyW/99KkF8+fnouOh2HmNo/nfaHZ14nqSN02gb3P0=; 3:kwpz7m1XPJVPaOGcloafq1Kzln10tGRP+5udWJWQ5r3Ga/N62a0oem/jX4+ZU1YJseK0BIU8bH5NgJQ8NXbPZtSU4EXC84OQIur930klNUgCPBaaZL+WwnGth7AlriuII8aYgKg6vjlud1I266RW8JQreT2rl8T0XvB9HJgxcaft9XVUcIA2iBKJdxYz4EQOqdRxQLeMAjmhhw0N2E7deNOic8VbIdmyGyv86MgvEkGGOVYA73By1scD6MXE2bAz+eu+XCQgcAjJrSZmaJz8ij6zoFbxXbDYFkQLubvs3gQ= X-MS-Office365-Filtering-Correlation-Id: 7dea5e54-fc4a-4c09-87e2-08d40a48c635 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002); SRVR:VI1PR0801MB1790; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1790; 25:SY26T4VN2dZqCnZYNnlB/TeUBawEhwJP+y38Nsz3mMrCNTHo7tOBLserBhj2j3pTRWxhQqtQrZXjEiZFQb18w8QKFdCvqTNAmu2JpskQxP6kDGmtw8Uuv88x81KvSVn86xDPqDoySYGAY8SN3i/vc9UT43uecUokle2vK/r5Qi4j4ama44qHj59KI0UPQ6c4dw4N/bxtx5bQYl49D4+BVW92Y72kLMCARh+R0x5oV9Q8+7qU7ZJkzC1CXLZ22/2y7c1KMVJT72xfQNW7YI9Y3pIjP7UEtWBOYcFIouRZFEzHK0OpcfhT2O6OXD4S5F80h5OLZosMQT6XiqKPCd+it+za6AGit5fWBbuXJRNaUn0nwZiZotjZPf+0FM9KuLHKG6S+MYsdZAR1fXEwy9c3pLlns23xbbYRU7LMZMUVuCjH48buVc9nq7PLSF60VWpbN2rH7AIn2KAWzfz29joUHvV/F6B8pe9SjRRSiu3HPbI=; 31:NxVqrOZU4lazzYeh2EPzoyzVwoXNZzdVzlEcVJDV1T4QJffSBgSbj7PpWACl7irwLSlMd5RFje9r/7HkZcPdgp/gORxaaCw63B9DooGOYnyt65uQ1cleROCrkXxghXWFpIdkEFExtBZouuZWvmGUlH2p4O2gFlTgwz5xSKOfT9T53T4bWZDbI/G6wdFt0pagU2I6taF3f0cJaGXukysNwqddzSHLJ6boTVnURSau2OX5uUEjYfFCg2TSE65MeUM2uuNyUU4VLHJvZfhln/pyUdW7SMi6PSSchIhDqfEFp9I= NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1790; 20:mMjyijfMw3aAs7216Aob2sKjgOiMZyI6ODhNFIlo2BY2h4qsFxTIz+vLfgFYv+hIxxUY+Jbu342tMHm8hePGJYEtuqltvqbtmKri1G41bInFvRR6n6fjEaFlNykV+ZBZuddp6wG4O9aQpxSftjZXFOdxZP6GXdsMt6LbMaFQvAqjKhwlXRkqi9QITkd7KnRlBNGOHOxVJizFS62a5cE/ZS8/oZguFFGKy+/h3rgm7EHhVxww4mZxFmoUNdIs9K6O; 4:cvtGMQxDWPzbWRUqhAFsmeNv87rT+Qi6bFSMVmCrTh/QBgWFaEJ2/lh3Ba/SuSa+4w5jpO8c3OjHIoa3l2KCj5cTCF5GI7+CnZRc8yORM5aGRSrwHgCVePozBTRu8EgLZKwhujwGBBlmvSmdVl7K5s4YKv1xOIgU6Mx/fBohueOTxNdHvlVWZ5CL/Qq06Fp7wwzUg6RckEd0PjhRen8StQdEcB4MTJKT1qWKlxZ9E0L5uCLRUeJN2q7uBHuZgbh4tMEK9ZL1HvQFNRq/+6vvT/LgGXM9n8rZxx7GZ5CkRpeT/BpN+eAUvQ+Kh6ilWnw/ZC4qMWEowHfgUGqjw4n5CqEHLA+xw8vBkIyt6xgkAOl6ahjeqp1f6f6e2obtBLg3y4YLyzOOciDeZ7zWxZ2QnfAtFEW5l3in/kwAFeLurjp+NWOlOkmby1nT/JPOMa/JBl2gePzjlJ88EfqAlJ6a5HY5EdLbGtSslav4eC0Z6HtLRg7MAUiNB9OEcXAlrwDW4h6S7xnl1E2lO+TYnwIzv+1AHb0iQUoY1/U/y5ezzt1IQWKFVpHSQX/iFq+AYn52n7tHDAvQUcSBW213ZIg3jp/vXJI0Wk66dOXiB8IqJ5Ivq6OFj3O/aEr/0Zyuexq0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(22074186197030)(183786458502308); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(102415395)(6040176)(601004)(2401047)(5005006)(13024025)(8121501046)(13013025)(13020025)(13023025)(10201501046)(3002001)(6055026); SRVR:VI1PR0801MB1790; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1790; X-Forefront-PRVS: 012349AD1C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1790; 23:xPqxecbUIaBoE9KUyW8HkvlhHavHMYhVklApo/U?= =?us-ascii?Q?r4RYsBnrlZqjHQjgp/5GsDddQnSqgSiAuPWTGJeTmg5LDu92MhTa0XBzr+Gq?= =?us-ascii?Q?xR4nN+JYG93KXfT6utZd0vHQptlM07GYHLadkkmmTmZAgRzAFnwM3lssibBh?= =?us-ascii?Q?eRz8wBBWrioA9eN7Pob3or5CFzVfJTpwIWYjPzELSFEfCst6PvANhwEmCKw0?= =?us-ascii?Q?gnEgGjRr1/OEXmIPLNrDmc5Bt/auNKCg038xJcykRNyP9chxMTswKNkWOSqF?= =?us-ascii?Q?+u/dIGCU964y3qDDb/ANoybMNom7aI56CXs/oTaKhXiPuRm45z7n/3ptxRnT?= =?us-ascii?Q?9JTF49q8CLzhfGGo0RAEnYx7M0qDiHgADXLzjQi3T7vo5SlMKwD4whUpnBHR?= =?us-ascii?Q?T/im9ryQ4D4TVqqSSkpN+Wan4yfhNoCNluP0oGoMZOGng1+3CMen54dNW4Ku?= =?us-ascii?Q?DUdyzv0rdlO1M7mg3DwmYJ1oVn2XaZkNTP6ZkgdlPfsJIcfiust2S1tRc1wX?= =?us-ascii?Q?9X8BtCF3XQbageFNj+pWfAAOQt9hqFvFJGsHkgEcPmwL6vTNziB/heQDH21K?= =?us-ascii?Q?vqHUUaCGIbf8mQrxlnwFMilVMPSK2xLwowA3gImFghytjntwD1E4XVrTDcyc?= =?us-ascii?Q?47LeJh/27bkA9RSEgCi21oJH9qRUecE1JZZBX+/qFB9HWAAYT9AyQxYN6CvA?= =?us-ascii?Q?W3H6S6Ncs0MBgmS6+UuiyLmdNxD7hcNyPHeWO4NSCtuBl+ix3+VPQih6N1VU?= =?us-ascii?Q?KujzOCtHNM/Ijlw+ZYOa4qcJRJww5TlHkVTkzvU19Dn3b7SO2EDHhwRn1LYm?= =?us-ascii?Q?nBruFO8PLsqNhUnpApK5E9LmdUwy7a2NMywwM4zeOhuPokZ0uF+wcH054DiK?= =?us-ascii?Q?qgMpdRsn/8ZuVAtUrjzl4mesuULh143kIP6ZxWaxWgEI5PhNn2eC7IZC6BLk?= =?us-ascii?Q?qsUPVl4XDQxM/1RLp0+MVuhdacXmDBSJPVXZmMK5g5MLTdZk55ZRW0q+X17W?= =?us-ascii?Q?7JjFFQv98cptZ6Bepj+0eBLg81ueDRqoQK9+RxJ240SLUnDXdOcaYnQFrQlu?= =?us-ascii?Q?I33GaA5K+hieZ0nQfodMHRHBPVmBV?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1790; 6:mRea/qooVBf1AoLbDAbYmBIxdRSJEjBQyFIQLQla+2y/w6WumJr4nLHKL5qAs4BmJOs9iX269LV9YY4fE6x51MxZukyRbxuWsnauaKJFEXjx4iXMST/ya56ELbWlNpaDpc4bOQI6ECQAWNPvMl0TY5GG33/fpzHcOnqodYLVzV+U1G1k50Ic8f3ayPXGSEvDoL/H56mzaBtDOo+na90mZu7vP3eL9hhvXie4JpXYdL1RQ3o7KGEzQvZAATSor/E0OaYC4v4PSUqvP5kn6UcnR3BMoEmuYDpAx3yG821nA11PHYVEFoL8snZdjqGhEFzZ9rZhBldFJk1/n+9by7TcRlymlDJ9l5YkNYHP33o7lpw=; 5:dGu59WsW5NDKV3hndYtV17Cn1UuUCSL/HXKgOcW0O8J3ZEGkcc+Ls1RMr+/dkSh0kc9NLcogm0/oaHwXW1k8Du6WsqukYwDDtGlCjjOaPJ3vDeGfDSkh2vtdYXb6UIaTN+WHPWhLlFCsWwt1PGRo3bAduPyuV/u38C3HkYnOav0=; 24:1mU8mV/EeTiGSZM3BeeWTPCRfsU3gYCnID/al7355JrItKS/C6pt+5LPa2ko1bDySWJ78HIbuWyBPudYT2pUIhatasueVNKt7fu4YGQjOs8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1790; 7:qeBfs/Xig/ENJL3KNqTjs6Gg1Ul3Hr87kN7NbcWJRtMzpB6Doa0qb+WzZIPJc0hTze6KKKOP+YdWteyy3BOuXZsPPtYLAVEWGExSvXoyePlPlkaJAyF/DYZpe/G8jz5zVq+x6ldPH+NdN05pj7RMtdrgUPpu0DNQmFSj6YUJiOQZjxkpD+R54CwXBmo1Vk2WnF6gvXpbl5m7Agr/HV9BieACbv9CVSn3Qm7GUc9A8XDSUE/RYUw0PoXY8uY/nJfUsZqcPaVBfShEGFrB8g9GAdQHY5Q/APWA/SOy1bJarXmNvRdoENNQZo1L11gh4LOYBMLP7CsBWKB7Kqn40Du/OxnXvrZ4NaSKbVfQGqmET2E= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2016 15:38:24.2594 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1790 X-IsSubscribed: yes --- This patch was approved here: https://gcc.gnu.org/ml/gcc-patches/2016-09/msg02405.html Joseph had a comment in https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00335.html that the tests should check FLT_EVAL_METHOD from rather than __FLT_EVAL_METHOD__. Rather than implement that suggestion, I added tests to patch 6 which tested the macro, and left the tests in this patch testing the internal macro. --- Hi, This option is added to control which values of FLT_EVAL_METHOD the compiler is allowed to set. ISO/IEC TS 18661-3 defines new permissible values for FLT_EVAL_METHOD that indicate that operations and constants with a semantic type that is an interchange or extended format should be evaluated to the precision and range of that type. These new values are a superset of those permitted under C99/C11, which does not specify the meaning of other positive values of FLT_EVAL_METHOD. As such, code conforming to C11 may not have been written expecting the possibility of the new values. -fpermitted-flt-eval-methods specifies whether the compiler should allow only the values of FLT_EVAL_METHOD specified in C99/C11, or the extended set of values specified in ISO/IEC TS 18661-3. The two possible values this option can take are "c11" or "ts-18661-3". The default when in a standards compliant mode (-std=c11 or similar) is -fpermitted-flt-eval-methods=c11. The default when in a GNU dialect (-std=gnu11 or similar) is -fpermitted-flt-eval-methods=ts-18661-3. I've added two testcases which test that when this option, or a C standards dialect, would restrict the range of values to {-1, 0, 1, 2}, those are the only values we see. At this stage in the patch series this trivially holds for all targets. Bootstrapped on x86_64 with no issues. Thanks, James --- gcc/c-family/ 2016-11-09 James Greenhalgh * c-opts.c (c_common_post_options): Add logic to handle the default case for -fpermitted-flt-eval-methods. gcc/ 2016-11-09 James Greenhalgh * common.opt (fpermitted-flt-eval-methods): New. * doc/invoke.texi (-fpermitted-flt-eval-methods): Document it. * flag_types.h (permitted_flt_eval_methods): New. gcc/testsuite/ 2016-11-09 James Greenhalgh * gcc.dg/fpermitted-flt-eval-methods_1.c: New. * gcc.dg/fpermitted-flt-eval-methods_2.c: New. diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index de260e7..57717ff 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -788,6 +788,18 @@ c_common_post_options (const char **pfilename) && flag_unsafe_math_optimizations == 0) flag_fp_contract_mode = FP_CONTRACT_OFF; + /* If we are compiling C, and we are outside of a standards mode, + we can permit the new values from ISO/IEC TS 18661-3 for + FLT_EVAL_METHOD. Otherwise, we must restrict the possible values to + the set specified in ISO C99/C11. */ + if (!flag_iso + && !c_dialect_cxx () + && (global_options_set.x_flag_permitted_flt_eval_methods + == PERMITTED_FLT_EVAL_METHODS_DEFAULT)) + flag_permitted_flt_eval_methods = PERMITTED_FLT_EVAL_METHODS_TS_18661; + else + flag_permitted_flt_eval_methods = PERMITTED_FLT_EVAL_METHODS_C11; + /* By default we use C99 inline semantics in GNU99 or C99 mode. C99 inline semantics are not supported in GNU89 or C89 mode. */ if (flag_gnu89_inline == -1) diff --git a/gcc/common.opt b/gcc/common.opt index 314145a..915c406 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1326,6 +1326,21 @@ Enum(excess_precision) String(fast) Value(EXCESS_PRECISION_FAST) EnumValue Enum(excess_precision) String(standard) Value(EXCESS_PRECISION_STANDARD) +; Whether we permit the extended set of values for FLT_EVAL_METHOD +; introduced in ISO/IEC TS 18661-3, or limit ourselves to those in C99/C11. +fpermitted-flt-eval-methods= +Common Joined RejectNegative Enum(permitted_flt_eval_methods) Var(flag_permitted_flt_eval_methods) Init(PERMITTED_FLT_EVAL_METHODS_DEFAULT) +-fpermitted-flt-eval-methods=[c11|ts-18661] Specify which values of FLT_EVAL_METHOD are permitted. + +Enum +Name(permitted_flt_eval_methods) Type(enum permitted_flt_eval_methods) UnknownError(unknown specification for the set of FLT_EVAL_METHOD values to permit %qs) + +EnumValue +Enum(permitted_flt_eval_methods) String(c11) Value(PERMITTED_FLT_EVAL_METHODS_C11) + +EnumValue +Enum(permitted_flt_eval_methods) String(ts-18661-3) Value(PERMITTED_FLT_EVAL_METHODS_TS_18661) + ffast-math Common Optimization diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index f133b3a..75ff8ec 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -378,7 +378,8 @@ Objective-C and Objective-C++ Dialects}. -flto-partition=@var{alg} -fmerge-all-constants @gol -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves @gol -fmove-loop-invariants -fno-branch-count-reg @gol --fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse @gol +-fno-defer-pop -fno-fp-int-builtin-inexact @gol +-fpermitted-flt-eval-methods=@var{standard} -fno-function-cse @gol -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole @gol -fno-peephole2 -fno-sched-interblock -fno-sched-spec -fno-signed-zeros @gol -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol @@ -9155,6 +9156,30 @@ Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions generate a call to a library function then the ``inexact'' exception may be raised if the library implementation does not follow TS 18661. +@item -fpermitted-flt-eval-methods=@var{style} +@opindex fpermitted-flt-eval-methods +@opindex fpermitted-flt-eval-methods=c11 +@opindex fpermitted-flt-eval-methods=ts-18661-3 +ISO/IEC TS 18661-3 defines new permissible values for +@code{FLT_EVAL_METHOD} that indicate that operations and constants with +a semantic type that is an interchange or extended format should be +evaluated to the precision and range of that type. These new values are +a superset of those permitted under C99/C11, which does not specify the +meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code +conforming to C11 may not have been written expecting the possibility of +the new values. + +@option{-fpermitted-flt-eval-methods} specifies whether the compiler +should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, +or the extended set of values specified in ISO/IEC TS 18661-3. + +@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. + +The default when in a standards compliant mode (@option{-std=c11} or similar) +is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU +dialect (@option{-std=gnu11} or similar) is +@option{-fpermitted-flt-eval-methods=ts-18661-3}. + @item -fsingle-precision-constant @opindex fsingle-precision-constant Treat floating-point constants as single precision instead of diff --git a/gcc/flag-types.h b/gcc/flag-types.h index 6c5a4cc..d69f8f4 100644 --- a/gcc/flag-types.h +++ b/gcc/flag-types.h @@ -158,6 +158,14 @@ enum excess_precision EXCESS_PRECISION_STANDARD }; +/* The options for which values of FLT_EVAL_METHOD are permissible. */ +enum permitted_flt_eval_methods +{ + PERMITTED_FLT_EVAL_METHODS_DEFAULT, + PERMITTED_FLT_EVAL_METHODS_TS_18661, + PERMITTED_FLT_EVAL_METHODS_C11 +}; + /* Type of stack check. */ enum stack_check_type { diff --git a/gcc/testsuite/gcc.dg/fpermitted-flt-eval-methods_1.c b/gcc/testsuite/gcc.dg/fpermitted-flt-eval-methods_1.c new file mode 100644 index 0000000..c022f86 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fpermitted-flt-eval-methods_1.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-std=c11" } */ + +/* Test that we only see the C99/C11 values for __FLT_EVAL_METHOD__ if + we are compiling with -std=c11. */ + +int main (int argc, char** argv) +{ + switch (__FLT_EVAL_METHOD__) + { + case 0: + case 1: + case 2: + case -1: + return 0; + default: + return 1; + } +} diff --git a/gcc/testsuite/gcc.dg/fpermitted-flt-eval-methods_2.c b/gcc/testsuite/gcc.dg/fpermitted-flt-eval-methods_2.c new file mode 100644 index 0000000..a76ea7e --- /dev/null +++ b/gcc/testsuite/gcc.dg/fpermitted-flt-eval-methods_2.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-fpermitted-flt-eval-methods=c11" } */ + +/* Test that we only see the C99/C11 values for __FLT_EVAL_METHOD__ if + we are compiling with -fpermitted-flt-eval-methods=c11. */ + +int main (int argc, char** argv) +{ + switch (__FLT_EVAL_METHOD__) + { + case 0: + case 1: + case 2: + case -1: + return 0; + default: + return 1; + } +}