From patchwork Fri Sep 30 16:56:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 677141 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 3slyLC0mrcz9sRZ for ; Sat, 1 Oct 2016 02:57:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=l0xnwVwU; 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=e6h0/vUcRNsV0ewC gZIivtz6I6qnCG+1PGCaMtiLumS7+5J07voI3ye7bsJcETanSwXUSKIzFW1QCo6b SjpJQc0aWwKooD6bSwIf3i4vdzRj1WjogwP5ft0EAXUtZgqol1XZdBxr5c1yHFUw kNS4Q1XzlaXxohLhhVmfeJ7dQV0= 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=zbz4WzEJISBGYpctu+WavL kty4w=; b=l0xnwVwULLsGkgAsi0lXFMwojUHASK1+34BGQv8EEQaQ7YLK8ZQBLT 8XE/RipXm9FI61djjv7dd9klJmdroDSZJCVkxvvi91mXImvRGmwmPJvmbT2DeP9b dcwZpKL/Y7ftFKKgcfeEKIZ9JVrD8TOO4G/XqOeCKWo9lQKr8naWU= Received: (qmail 60900 invoked by alias); 30 Sep 2016 16:57:26 -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 60864 invoked by uid 89); 30 Sep 2016 16:57:25 -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, SPF_PASS autolearn=ham version=3.3.2 spammy=compliant, sk:james.g, jamesgreenhalgharmcom, U*james.greenhalgh X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Sep 2016 16:57:21 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03lp0116.outbound.protection.outlook.com [213.199.154.116]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-58-Don6ely3PJW4qhEe8u7HCg-1; Fri, 30 Sep 2016 17:57:17 +0100 Received: from HE1PR0801CA0002.eurprd08.prod.outlook.com (10.167.184.12) by VI1PR0801MB1454.eurprd08.prod.outlook.com (10.167.210.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16; Fri, 30 Sep 2016 16:57:16 +0000 Received: from DB3FFO11FD031.protection.gbl (2a01:111:f400:7e04::192) by HE1PR0801CA0002.outlook.office365.com (2603:10a6:3:6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16 via Frontend Transport; Fri, 30 Sep 2016 16:57:15 +0000 Received: from nebula.arm.com (217.140.96.140) by DB3FFO11FD031.mail.protection.outlook.com (10.47.217.62) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.629.5 via Frontend Transport; Fri, 30 Sep 2016 16:57:14 +0000 Received: from e107456-lin.cambridge.arm.com (10.1.2.79) by mail.arm.com (10.1.106.66) with Microsoft SMTP Server id 14.3.294.0; Fri, 30 Sep 2016 17:57:08 +0100 From: James Greenhalgh To: CC: Subject: [Patch 5/11] Add -fpermitted-flt-eval-methods=[c11|ts-18661-3] Date: Fri, 30 Sep 2016 17:56:54 +0100 Message-ID: <1475254617-10825-3-git-send-email-james.greenhalgh@arm.com> In-Reply-To: <1475254617-10825-1-git-send-email-james.greenhalgh@arm.com> References: <1475254617-10825-1-git-send-email-james.greenhalgh@arm.com> MIME-Version: 1.0 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)(377424004)(199003)(189002)(87936001)(6916009)(246002)(586003)(84326002)(189998001)(4326007)(7846002)(356003)(36756003)(19580405001)(19580395003)(229853001)(5890100001)(104016004)(305945005)(86362001)(2476003)(8676002)(2906002)(50226002)(568964002)(8936002)(5660300001)(26826002)(512874002)(110136003)(2950100002)(6666003)(626004)(77096005)(230783001)(2351001)(106466001)(450100001)(76176999)(50986999)(33646002)(92566002)(4610100001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0801MB1454; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD031; 1:sXEAMhgmcQgfXFUQr2C9NJF2ocxnR3Tb9vR5CsTrv1acZJCDO5xJyVpAAJkXhGQg9uXrSrzsjbCKLJL4mx9Zdr0WcAcF1yvLCzkAfCvyaRdQ+OUa8FBwZquhZ8KO3boyPDBU8HanDq+HXJBgfvEGm+p2qGuQJ+m9XyeuSciO/gOsC6T8Z/pt1eYwT9gK8/3AHdx0tR3k3eteld/DQyRzXKYz0z7Owr9wkCxNQDf28LsO5CYxvCCIR7FAF2Vl/UJX8Q0oR+NawAda7JCia08jTd678UYVKrjKrTfbe2SBuSMmKnhIADo5y8Tvy3uVtwCj7YzUziywlBuwlXX9LVJ2ZOZ67temBVA4uxK6KowSkGc1lp3bnj7f3HN2oPgTpcU3W6UqEJRHrRVEC7ZiCZ5kY80jYcdCn03RqsJLDofWlyntSxH4VSKpo5Y1OZlW3TpqjFjv8MSVddxWO7uGNUBHOlfG5EL3AkLgYy2d5i2LAa4ocFN1zIuCN5XApChDM4CShnqopXT/Mn6rRiaR36QnBrRKHBFc7HoS+HNHmMT65ohmnKmTUNGwbwvnkKPkkXvx X-MS-Office365-Filtering-Correlation-Id: 1268ba5e-3f3d-40aa-c58f-08d3e952d491 X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1454; 2:FmnFT83DLGDP77rhlRnwC1DXiDesv7x0gYc2gRdGzQfrS+a9sbgmwxDLoEMiVnPIUTVlGOStT7GwCR9uQwlpAOoLqqiPdIGb8WkCoUbVUv6SLhUIirxzifx1P4A/jucFUccZZhyTG7MhTVGCyOLeWNhI/gBk/3tufqWPlXBqMgwkEO0WxM6K5BIPhUj1ctF7uySB8mlwWadt/TH5eV8lNw==; 3:NnFBw0np9eTQA+eo3PvJyPqxFbP+ndnSRY8gGSqZUGvbCdm/B0KxnQcIRAGJHKKufQgHJXCOtD4XHPUu9jjOgET0rizn+fhnasTPcseWhyFtfD/g05qwVNlz6oTMPPbFDxK189Pdj1BjWA3vyHiXaJu5EaumA5y0+Hx6RIj3yWO0NNalPNDt7T9nvQFlSo8MVg2MLptjn2Tbeg78BXlBF3lOGPVQBNvaZyrFwOTVO/MmFDkIOvsNYU0rzjswMCJUjkkkVggoeopj5Q5X3ALlWtQhBFf3y93YkzZcJi7vumI= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:VI1PR0801MB1454; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1454; 25:iD5SbshPAlBAR+okh/2A4XMaF0q2HY4Y2561FiN+r6s1v2xW8OfXBBSomY37REg6zgDbW/3hKrIi7TD9VdbpA6q98AQ55lnOMSNDmCM/YeGC5GkKlqnJ3fey2aef4MR+tM6Ld7b+PJw1pSqJhF4M3VDBCG0zLUkzHkw9xgiNjLH12Ma3V2MfTiveRo3W9nX9pNm4FM8vby70efVIfAplU0UDOl+dX6qMJXV7TSrJ4tNkvPBvoIv/L0NeYA+2RT37g5Mi+sNemPAPdjwWFwfafzdz9+5dyZEaUljB/Dc0FsjYtvP/bxSPG4ObDItPlwPzs16EbPbLJglt7d/S2c79zWqTtn7OLD5/XYrLteVHkOFNHqJUtqy/TIqdf35R0A+i/JdTpKcclPXzbXkvIETVKp87ulCDaX71CKt0uj5Ss3CCMJL8SiAjgHobOsJ79PIVWYTMEKWun88VZ2ajhjy/AcIQxBn8JwLxU1hLTHYCy+ZU+5UewigKhGePr0wJIMm5; 31:x12QlooAgwpUgakn/VBts103cRFJ+Wtkb4hIq58RGIgCx/RAg/bxse/bWXBwM7mcpg/8IhyylKVw4cI9unePGRb2nzuY9O1nJZ+0E461KcvoH6JTQfa3Y/u5TzHTdlLIB5cWSu3v6lMbX+5Hmg0uA6KGsG3mC50zbcliGguhh68nRH9JNtK1Nw6GjOxI9/uNbtRgjcn1bWrSP6rdaFNKCpsbnjVNuv6/qvXtlNS7LqGsMRovbSGuMGkmcFhmpcmGaCJHy4w953y/8XsOLypf0A== NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1454; 20:bb3FGRhP5Hb/y3R2dJkSzEAx17NePUxJCKmuOQHNpYExWebuUq+2v6dk1TgVHiaziiRT8wYiw/UjKaD2EA23AyB1MnfuZ4WpJJbDeMe+DqEvPi56+57rFiUUCwILSWQPJcGa80Z6rMHIB+iL/Kgar40N+PKLke7tbVgU6VoNhoWXIRQHUHgvWqFuUluLEDsPZwETWi3Tv+yznyH34FHKXMGq/1F9eB4lYn4ZghKCunqk0Vo/5KThRcLUznzrFwqb; 4:muoGblBCgpM7PexH2KLRio8aRMdPOsywnHeoQaxrj+D9bdotCAFRlUt9FHlg6Es8D+CHyeMqhyYFPVkOX+cSqI2RMcZ0yppL1rAvb1heN2muzdE5q5dWszWix3esq5XWA193ZtCmHFtwugBBIyXkLwTKqUz0DQ6BVkQuZxubyB0kQ6w290ZirLqL8CFA1tS89IXRv/yNsjDQuZ1+Y2Gw5yeUBKTb81GGS6VmOrfzGS48S3Yt/fDzW7oUxHIQxS8I11BkiexkODVsrJEM9ONx00nowIpBfeGd2oIr9CBAb7u/jJdld3PAPW/Ny/tdPRm81utkxIgkKxdSEFZbfBIhlhH1evADvUv4qRl2fRlhHklVPFq1FTDNaNSo2XKjoyEX6bsfwZb8vuDfzl+KhngCDfwO0LwPA/NV0uf5mKSSELCFrdsUf+BdJKMHMlSvm1wysE53Xdfc/tkUg41Trg1GaiRSRfz0VLLuxn26/Jaexj4egKQCXIKjWyJWpomYvoFfY/0Ve+daaGOkHyNgUmEhPcBk0AyIJtJZuEH9+Mm83WUp4HTCyJac1qf/w1IIvGWI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(102415321)(6040176)(601004)(2401047)(13024025)(13013025)(13023025)(8121501046)(13020025)(5005006)(10201501046)(3002001)(6055026); SRVR:VI1PR0801MB1454; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1454; X-Forefront-PRVS: 008184426E X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1454; 23:WQK/xEUw9vgpxPZAwZRkezH+v1gXEGQgRgulVQ0?= =?us-ascii?Q?gAKr3SNG1bpZE54Syljvaxwp+Ha8X3rJrOReZT0PjFBclxvx1/C90S1zaUm4?= =?us-ascii?Q?Qf8tVpy3ZcpvXWBUNDlH1th2UDvF4Qh67qU0wMsyvxEr51i3f0uNcjqQUsAd?= =?us-ascii?Q?o40eC9nzIRlOHO2wkwhJeE739II6S8Wge5+GdwQOSmGtJGQx2oZQcZQHO3+c?= =?us-ascii?Q?28XSqT/CQQknJtMctfVIxcxx8dAjZAc17ZFsNYoVkBuqnWDigOmVek8qgYh3?= =?us-ascii?Q?zR0z628vhY91SwMEBxbFzoWFMjdfRFAqbJcY5/fm2wmIWhQENrKHr2xmwazd?= =?us-ascii?Q?Xxux9ARZDFcRlvoLD4nfJhIpC6AdUAx+udq7i7l2sOibLG1gx0jI76oh08OX?= =?us-ascii?Q?G0GxnZaUGLMpCAzA+zkPvQgJfEUQxrFrzy4mXQOubn/3iJ5xvvVK8ESF4OGp?= =?us-ascii?Q?XixCYN3mBWml9TU83++WkT7hChhqQtkuK2gytdDqySZF2+hDy7iwGBile3kF?= =?us-ascii?Q?SvXqy9FZqWxPE+z7c7+GplILG8CNVuK1P6JLiNf4UGh9gmrjNPkUyRsa9zWf?= =?us-ascii?Q?NakF8hu5bkWhbXvC08EBxSALng69BayWBKEU5WLLXjPMnhzPRZFj7dbJrXKa?= =?us-ascii?Q?i2zUn/Jl+I66Mtd3TNx4HwCbPIXwbNLJ2z45GLUZf+bYYrwMlsrIERqK+yLl?= =?us-ascii?Q?0ih1kcFQuNiTL51F2sBoGWUfyngY0cM8FvZKMFlIW0ydGXbFXOylD+mATXct?= =?us-ascii?Q?Fx/gyJXoaCy4UtPDfWDtBNFgWcG92+K0HQc9vihVgcxSL28et8vzuY3mi23A?= =?us-ascii?Q?kEWHdZ5tcGQ5cXL6mVZ70BLGXdt7NjORP/+RJPDpYJoUtEt/cGnlfs3T8UQI?= =?us-ascii?Q?10oNYG/Xcs0ksQJniyKR0RASH7Gg37frqDCGsXp3ME/1rr1IVkE8GsXQHS3x?= =?us-ascii?Q?+Cn6z4LMNB/dzVmvua2fL0SvaY0CDyz27WC+PO2FGB4EQNg+lRhHqwGch2NO?= =?us-ascii?Q?BlkyLWo6/7Wc36pPPfeWT6mQqdNIn5TPW2BPQaRW5da2Wc1qYIQ6VUcNREUp?= =?us-ascii?Q?8vzY8sBkeIscMYn00DGAGYM+XDmXFTJq2XYP3GwQL0sdu2PDcsx9SCfyeeZZ?= =?us-ascii?Q?aI1W+8LJ9y85ZVL+WwWRgXTNd7ZuYeEp0ROYob5MJuPOLhlrxCDxukw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1454; 6:EIypSHs8FKCLYfWsTWnYYUhgFyESU3VKnY34+jtCySWLmVuRNVR9n/dz6HqBvPadA19PE757nwTRmMB5JFaEBwPd/n7e9xbzGCA10ddME7wb0tNIX1jZXy1AJz1phXk+pakQ+F6sOluTZE7yTNvdjjR1YHgBIDQ76fbh/XvZC19l/YH9p5z6hxybteYfDlri+QlJCDtEaRFxrq/NRJc/dOk1hv/XrsWzHObceBAQKypr3wr+k1DmTYmoB3vO23xf3zMEFEdzNllD3WUmVz8FHDqbzYNN42RILCWU1vU/cGeyjbZarDS+AK8vcPZWuS9gvgbLXU6DIl5wTUiBaBtrcgd3hX7v8YwS05feC0oBEb4=; 5:zjx7v5nqn//p3HLVxg+ff7exoPJO7mIlxjJxEZq2hVFzstUZSd4OKD0t88vuFIGfyGYCXF46B2Cw4y4YoECbx2Zdg+0Ic5gNCQyp+WDnvULAeEGgbommkyChK1O0vd0VkKwJZbQCSJfGMs+6hdIZTenrdu8gAwJ6QztmDsIeVuE=; 24:rkv3O9yNYLQNHolzkPScyyDLXnvPnGnMXqo4S1j+L7p5C/xXKHTNmzp7aAwyTxurmOk9sGBV7yeN2MmwBprf5WZoXDawBsAUGV+XIfmuAao= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1454; 7:v8CaoN46h88n/JU3F0H3AaTJuZ6P+m2fPG5QOwAyHq74aEFy3wmu6ke5r8b3yL/gsl7/TDsUkTRW2KHTIjt+9eY4AKW5WragBHdF73o0PMIdIqdf6p9nfHFCyvRju4OxVr2uakn0HQHVaP06yzjM0yGrF5nOCMB2gWd2MzTPJ2pICswBCw1+4xKqApDYQ46hH/p57AgW827jb1iUonEefO2KxTyTwPZO7doY7Ek3004vRCwoxltMpMI+UBZCfy5aF0vH2BEtWe9vodFVT167jVrkv+4+lgAucQMKO1vd34Z5VMa3++2Qc9L/NJAO6c3D+u/TrjdgcaVwV8yCtiNiIw==; 20:VCsqv0ZnzYcYEzcgGqTYTQ54kKhI7RMiu4bTEpHL3QDSPnzY/LWqeeRGTx3kaiBCjVcE/ehfIH4lFNW7InPv8qqFObEXxH9uVCVqT1LWVi67Ub/nq3SpXqp4ia0+HnDT1QlZv3W80F7yQij3EzGQ5ydsI4aqwjW+0u7Yb8B81o4= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2016 16:57:14.9789 (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: VI1PR0801MB1454 X-MC-Unique: Don6ely3PJW4qhEe8u7HCg-1 X-IsSubscribed: yes 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 and tested in series on AArch64. OK? Thanks, James --- gcc/c-family/ 2016-09-30 James Greenhalgh * c-opts.c (c_common_post_options): Add logic to handle the default case for -fpermitted-flt-eval-methods. gcc/ 2016-09-30 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-09-30 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 c5a699d..af8d7fe 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -789,6 +789,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 0e01577..3a22aa0 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1305,6 +1305,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 8a84e4f..9cb0b54 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -375,7 +375,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 @@ -8917,6 +8918,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 816df6b..ac3075b 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; + } +}