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 <ja...@redhat.com>
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 }