From patchwork Fri Feb 17 23:04:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 729385 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 3vQ7sl1fHyz9s80 for ; Sat, 18 Feb 2017 10:05:29 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NXJP+t24"; 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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=E6HeRN6pgYvhaIfnD3C/XYcMnyos+Q690ZATE2D9ASMZK6nq4QPwB W2qZqeBDLH8ggsJseg/tX20FzfIQb8DgT4i7k+vLSbOQIwkhVoSrDXn75BTSFXpH cFOpHmEgU6ULVWADS9ekSB60fjKbVpRR2XNxRuZsIw6NbiV0cNl2NM= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=1kHrCSSWuW75+R+TVAITIfgcc9A=; b=NXJP+t24NvtuLqFrvZyF nxFrN+vdhXqLry+poAtC7AqTb0sQRVWJnhsWnezS2bSBswNjBDLDMLU9YVFi9fpb SY6IeA2KZNG/7RQm9HKHNyS0SqXSBQpYxRp0p7k0+jUD5XGNyasaobRf7Gw1hkdH 1pArl+ouAVhGOoiwE5wNbsg= Received: (qmail 32281 invoked by alias); 17 Feb 2017 23:05:21 -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 32259 invoked by uid 89); 17 Feb 2017 23:05:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Feb 2017 23:05:10 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ceraN-0004N8-Ax from joseph_myers@mentor.com for gcc-patches@gcc.gnu.org; Fri, 17 Feb 2017 15:05:07 -0800 Received: from digraph.polyomino.org.uk (137.202.0.87) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Fri, 17 Feb 2017 23:05:04 +0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.86_2) (envelope-from ) id 1ceraF-0004hT-Vl for gcc-patches@gcc.gnu.org; Fri, 17 Feb 2017 23:05:00 +0000 Date: Fri, 17 Feb 2017 23:04:59 +0000 From: Joseph Myers To: Subject: Restore DECIMAL_DIG macro to C99/C11 value Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) By extending the set of floating types, TS 18661-3 thereby affected the definition of DECIMAL_DIG, which is defined in terms of the "widest supported floating type". This is not conditional on whether __STDC_WANT_IEC_60559_TYPES_EXT__ is defined when is included. I raised this possible incompatibility with C11 (an implementation should be able to conform simultaneously with C11, and with C11 + TS 18661) in DR#501. This is not yet resolved, but the latest proposal would obsolete DECIMAL_DIG with the intention of limiting it to the C11 types (so making it equivalent to LDBL_DECIMAL_DIG). (This proposal is intended to go along with a corresponding change to TS 18661-3 to avoid the new types and non-arithmetic interchange encodings affecting the value of DECIMAL_DIG.) To avoid releasing GCC 7 with a wider-than-C11 value of DECIMAL_DIG and possibly reverting back to a C11 value in a future release, this patch reverts back to the C11 value now. If the proposed resolution to DR#501 changes again so that DECIMAL_DIG *should* have a wider-than-C11 value, we can move back to a wider-than-C11 value in GCC 8. Bootstrapped with no regressions on x86_64-pc-linux-gnu. Applied to mainline. gcc/c-family: 2017-02-17 Joseph Myers * c-cppbuiltin.c (builtin_define_float_constants): Define __DECIMAL_DIG__ to the value for long double. gcc/testsuite: 2017-02-17 Joseph Myers * gcc.dg/c11-float-2.c: New test. * gcc.dg/torture/float128-floath.c, gcc.dg/torture/float128x-floath.c, gcc.dg/torture/float16-floath.c, gcc.dg/torture/float32-floath.c, gcc.dg/torture/float32x-floath.c, gcc.dg/torture/float64-floath.c, gcc.dg/torture/float64x-floath.c: Do not test comparison of *_DECIMAL_DIG macros with DECIMAL_DIG. Index: gcc/c-family/c-cppbuiltin.c =================================================================== --- gcc/c-family/c-cppbuiltin.c (revision 245538) +++ gcc/c-family/c-cppbuiltin.c (working copy) @@ -245,11 +245,10 @@ builtin_define_float_constants (const char *name_p if (type_decimal_dig < type_d_decimal_dig) type_decimal_dig++; } - /* Arbitrarily, define __DECIMAL_DIG__ when defining macros for long - double, although it may be greater than the value for long - double. */ + /* Define __DECIMAL_DIG__ to the value for long double to be + compatible with C99 and C11; see DR#501 and N2108. */ if (type == long_double_type_node) - builtin_define_with_int_value ("__DECIMAL_DIG__", decimal_dig); + builtin_define_with_int_value ("__DECIMAL_DIG__", type_decimal_dig); sprintf (name, "__%s_DECIMAL_DIG__", name_prefix); builtin_define_with_int_value (name, type_decimal_dig); Index: gcc/testsuite/gcc.dg/c11-float-2.c =================================================================== --- gcc/testsuite/gcc.dg/c11-float-2.c (nonexistent) +++ gcc/testsuite/gcc.dg/c11-float-2.c (working copy) @@ -0,0 +1,9 @@ +/* Test DECIMAL_DIG equals LDBL_DECIMAL_DIG; see DR#501 and N2108. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#if DECIMAL_DIG != LDBL_DECIMAL_DIG +# error "DECIMAL_DIG != LDBL_DECIMAL_DIG" +#endif Index: gcc/testsuite/gcc.dg/torture/float128-floath.c =================================================================== --- gcc/testsuite/gcc.dg/torture/float128-floath.c (revision 245538) +++ gcc/testsuite/gcc.dg/torture/float128-floath.c (working copy) @@ -53,10 +53,6 @@ # error "FLT128_TRUE_MIN undefined" #endif -#if FLT128_DECIMAL_DIG > DECIMAL_DIG -# error "FLT128_DECIMAL_DIG > DECIMAL_DIG" -#endif - #if FLT128_MANT_DIG != 113 || FLT128_MAX_EXP != 16384 || FLT128_MIN_EXP != -16381 # error "_Float128 bad format" #endif Index: gcc/testsuite/gcc.dg/torture/float128x-floath.c =================================================================== --- gcc/testsuite/gcc.dg/torture/float128x-floath.c (revision 245538) +++ gcc/testsuite/gcc.dg/torture/float128x-floath.c (working copy) @@ -53,10 +53,6 @@ # error "FLT128X_TRUE_MIN undefined" #endif -#if FLT128X_DECIMAL_DIG > DECIMAL_DIG -# error "FLT128X_DECIMAL_DIG > DECIMAL_DIG" -#endif - #if FLT128X_MANT_DIG < 128 || FLT128X_MAX_EXP < 65536 || FLT128X_MIN_EXP + FLT128X_MAX_EXP != 3 # error "_Float128x bad format" #endif Index: gcc/testsuite/gcc.dg/torture/float16-floath.c =================================================================== --- gcc/testsuite/gcc.dg/torture/float16-floath.c (revision 245538) +++ gcc/testsuite/gcc.dg/torture/float16-floath.c (working copy) @@ -53,10 +53,6 @@ # error "FLT16_TRUE_MIN undefined" #endif -#if FLT16_DECIMAL_DIG > DECIMAL_DIG -# error "FLT16_DECIMAL_DIG > DECIMAL_DIG" -#endif - #if FLT16_MANT_DIG != 11 || FLT16_MAX_EXP != 16 || FLT16_MIN_EXP != -13 # error "_Float16 bad format" #endif Index: gcc/testsuite/gcc.dg/torture/float32-floath.c =================================================================== --- gcc/testsuite/gcc.dg/torture/float32-floath.c (revision 245538) +++ gcc/testsuite/gcc.dg/torture/float32-floath.c (working copy) @@ -53,10 +53,6 @@ # error "FLT32_TRUE_MIN undefined" #endif -#if FLT32_DECIMAL_DIG > DECIMAL_DIG -# error "FLT32_DECIMAL_DIG > DECIMAL_DIG" -#endif - #if FLT32_MANT_DIG != 24 || FLT32_MAX_EXP != 128 || FLT32_MIN_EXP != -125 # error "_Float32 bad format" #endif Index: gcc/testsuite/gcc.dg/torture/float32x-floath.c =================================================================== --- gcc/testsuite/gcc.dg/torture/float32x-floath.c (revision 245538) +++ gcc/testsuite/gcc.dg/torture/float32x-floath.c (working copy) @@ -53,10 +53,6 @@ # error "FLT32X_TRUE_MIN undefined" #endif -#if FLT32X_DECIMAL_DIG > DECIMAL_DIG -# error "FLT32X_DECIMAL_DIG > DECIMAL_DIG" -#endif - #if FLT32X_MANT_DIG < 32 || FLT32X_MAX_EXP < 1024 || FLT32X_MIN_EXP + FLT32X_MAX_EXP != 3 # error "_Float32x bad format" #endif Index: gcc/testsuite/gcc.dg/torture/float64-floath.c =================================================================== --- gcc/testsuite/gcc.dg/torture/float64-floath.c (revision 245538) +++ gcc/testsuite/gcc.dg/torture/float64-floath.c (working copy) @@ -53,10 +53,6 @@ # error "FLT64_TRUE_MIN undefined" #endif -#if FLT64_DECIMAL_DIG > DECIMAL_DIG -# error "FLT64_DECIMAL_DIG > DECIMAL_DIG" -#endif - #if FLT64_MANT_DIG != 53 || FLT64_MAX_EXP != 1024 || FLT64_MIN_EXP != -1021 # error "_Float64 bad format" #endif Index: gcc/testsuite/gcc.dg/torture/float64x-floath.c =================================================================== --- gcc/testsuite/gcc.dg/torture/float64x-floath.c (revision 245538) +++ gcc/testsuite/gcc.dg/torture/float64x-floath.c (working copy) @@ -53,10 +53,6 @@ # error "FLT64X_TRUE_MIN undefined" #endif -#if FLT64X_DECIMAL_DIG > DECIMAL_DIG -# error "FLT64X_DECIMAL_DIG > DECIMAL_DIG" -#endif - #if FLT64X_MANT_DIG < 64 || FLT64X_MAX_EXP < 16384 || FLT64X_MIN_EXP + FLT64X_MAX_EXP != 3 # error "_Float64x bad format" #endif