From patchwork Tue Mar 15 12:08:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 597474 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 3qPYKz2xW5z9s3T for ; Tue, 15 Mar 2016 23:08:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=xZPU5psu; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=FVM+kbWtDx6kWgGVRxZMPpTmEbzT1U0qvcI2e/sOsaCJ432QJU fN/Qo7uIisQUiY7+IxUhuNBJtVLk5DSwtjXV8ko9xuPO50b5dkJA/kpSFJPWSy3Q gmyg9EeLwK7h0fa+brBiqvVEirQFjFAOdRoohzZZUdyBCVDWn07wcv3Ok= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=JSFS4QEq1XV5vP1Tehxkb2TMm5Q=; b=xZPU5psuGN8IWZ+MZxaH xhe6sq7whFeXzsiJtIzY5TYTsC5kPbhsMEFqjMSdyMqdIYPiYWpchDz4Ua4Aqfbo LQL2aTv1ngjpVNcxeIvFrBdOiaMMoDhGRhRrDMAb+egmE9WhQ8tAO+2DwN2hDVb1 Qa7dQ/TiSepfsSOJLfAq0ZY= Received: (qmail 26097 invoked by alias); 15 Mar 2016 12:08:11 -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 26085 invoked by uid 89); 15 Mar 2016 12:08:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 spammy=ASM, c1z, Arrays X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 15 Mar 2016 12:08:09 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 00880C0005D8 for ; Tue, 15 Mar 2016 12:08:07 +0000 (UTC) Received: from [10.10.116.38] (ovpn-116-38.rdu2.redhat.com [10.10.116.38]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2FC865x001220 for ; Tue, 15 Mar 2016 08:08:07 -0400 To: gcc-patches List From: Jason Merrill Subject: C++ PATCH for C++17 hex float feature test macro Message-ID: <56E7FB26.1070809@redhat.com> Date: Tue, 15 Mar 2016 08:08:06 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 Another C++17 feature that's trivial to implement, since it was already supported: hex floating-point literals. We just need to define the feature-test macro and correctly remove it from strict C++11/14 modes. Tested x86_64-pc-linux-gnu, applying to trunk. commit 7fc42c9d978983956029b2b401682d1aa58d8d27 Author: Jason Merrill Date: Fri Mar 4 21:38:21 2016 -0500 * libcpp/expr.c (cpp_classify_number): Hex floats are new in C++1z. * libcpp/init.c (lang_defaults): Likewise. * gcc/c-family/c-cppbuiltin.c (c_cpp_builtins): Set __cpp_hex_float. diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index dc1f426..ee953ca 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -818,6 +818,10 @@ c_cpp_builtins (cpp_reader *pfile) if (!pedantic || cxx_dialect > cxx11) cpp_define (pfile, "__cpp_binary_literals=201304"); + /* Similarly for hexadecimal floating point literals and C++17. */ + if (!pedantic || cpp_get_options (parse_in)->extended_numbers) + cpp_define (pfile, "__cpp_hex_float=201603"); + /* Arrays of runtime bound were removed from C++14, but we still support GNU VLAs. Let's define this macro to a low number (corresponding to the initial test release of GNU C++) if we won't diff --git a/gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C b/gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C index 39d9fe4..a0e468c 100644 --- a/gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C +++ b/gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C @@ -1,4 +1,4 @@ // { dg-do compile { target c++98_only } } /* { dg-options "-ansi -pedantic-errors" } */ -double x = 0x3.1415babep0; // { dg-error "use of C..11 hexadecimal floating constant" } +double x = 0x3.1415babep0; // { dg-error "use of C..1z hexadecimal floating constant" } diff --git a/libcpp/expr.c b/libcpp/expr.c index 5353bde..5cdca6f 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -552,7 +552,7 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token, { if (CPP_OPTION (pfile, cplusplus)) cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, - "use of C++11 hexadecimal floating constant"); + "use of C++1z hexadecimal floating constant"); else cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, "use of C99 hexadecimal floating constant"); diff --git a/libcpp/init.c b/libcpp/init.c index 6bc4296..4343075 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -105,9 +105,9 @@ static const struct lang_flags lang_defaults[] = /* GNUCXX */ { 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, /* CXX98 */ { 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0 }, /* GNUCXX11 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, - /* CXX11 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0 }, + /* CXX11 */ { 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0 }, /* GNUCXX14 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0 }, - /* CXX14 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + /* CXX14 */ { 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, /* GNUCXX1Z */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1 }, /* CXX1Z */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 }, /* ASM */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }