This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
c-family PATCH to update __cpp_constexpr macro for C++14 constexpr support
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 11 Dec 2014 22:47:12 -0500
- Subject: c-family PATCH to update __cpp_constexpr macro for C++14 constexpr support
- Authentication-results: sourceware.org; auth=none
A bit I forgot in the earlier C++14 constexpr work.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 0b9dbcebc4d3bf5e9281889f34d189fb7c42dde3
Author: Jason Merrill <jason@redhat.com>
Date: Thu Dec 11 22:19:36 2014 -0500
* c-cppbuiltin.c (c_cpp_builtins): Enable C++14 __cpp_constexpr.
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 54d3acd..2dfecb6 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -845,7 +845,8 @@ c_cpp_builtins (cpp_reader *pfile)
cpp_define (pfile, "__cpp_unicode_literals=200710");
cpp_define (pfile, "__cpp_user_defined_literals=200809");
cpp_define (pfile, "__cpp_lambdas=200907");
- cpp_define (pfile, "__cpp_constexpr=200704");
+ if (cxx_dialect == cxx11)
+ cpp_define (pfile, "__cpp_constexpr=200704");
cpp_define (pfile, "__cpp_range_based_for=200907");
cpp_define (pfile, "__cpp_static_assert=200410");
cpp_define (pfile, "__cpp_decltype=200707");
@@ -865,8 +866,7 @@ c_cpp_builtins (cpp_reader *pfile)
cpp_define (pfile, "__cpp_return_type_deduction=201304");
cpp_define (pfile, "__cpp_init_captures=201304");
cpp_define (pfile, "__cpp_generic_lambdas=201304");
- //cpp_undef (pfile, "__cpp_constexpr");
- //cpp_define (pfile, "__cpp_constexpr=201304");
+ cpp_define (pfile, "__cpp_constexpr=201304");
cpp_define (pfile, "__cpp_decltype_auto=201304");
cpp_define (pfile, "__cpp_aggregate_nsdmi=201304");
cpp_define (pfile, "__cpp_variable_templates=201304");
diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C
index d271752..36e1135 100644
--- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C
+++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C
@@ -47,12 +47,6 @@
# error "__cpp_lambdas != 200907"
#endif
-#ifndef __cpp_constexpr
-# error "__cpp_constexpr"
-#elif __cpp_constexpr != 200704
-# error "__cpp_constexpr != 200704"
-#endif
-
#ifndef __cpp_range_based_for
# error "__cpp_range_based_for"
#elif __cpp_range_based_for != 200907
@@ -145,11 +139,10 @@
# error "__cpp_generic_lambdas != 201304"
#endif
-// TODO: Change 200704 to 201304 when C++14 constexpr goes in.
#ifndef __cpp_constexpr
# error "__cpp_constexpr"
-#elif __cpp_constexpr != 200704
-# error "__cpp_constexpr != 200704"
+#elif __cpp_constexpr != 201304
+# error "__cpp_constexpr != 201304"
#endif
#ifndef __cpp_decltype_auto