On Wed, Aug 10, 2016 at 5:57 PM, Jason Merrill <ja...@redhat.com> wrote: > This patch implements the C++17 constexpr if feature. The primary use > is in templates, where the non-taken branch of the constexpr > if-statement is not instantiated. But it can also be used outside of > templates, where the branches are parsed and discarded, and discarded > return statements are not used for return type deduction.
...and the feature test macro.
commit 1f20a739d61ef839ec7091aa1278adf6d726ead4 Author: Jason Merrill <ja...@redhat.com> Date: Wed Aug 10 18:35:01 2016 -0400 * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_if_constexpr. diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 46c70ac..82ed19d 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -882,6 +882,7 @@ c_cpp_builtins (cpp_reader *pfile) cpp_define (pfile, "__cpp_nontype_template_args=201411"); cpp_define (pfile, "__cpp_range_based_for=201603"); cpp_define (pfile, "__cpp_constexpr=201603"); + cpp_define (pfile, "__cpp_if_constexpr=201606"); } if (flag_concepts) /* Use a value smaller than the 201507 specified in diff --git a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C index f5ed6ab..41b6111 100644 --- a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C +++ b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C @@ -344,6 +344,12 @@ # error "__cpp_hex_float != 201603" #endif +#ifndef __cpp_if_constexpr +# error "__cpp_if_constexpr" +#elif __cpp_if_constexpr != 201606 +# error "__cpp_if_constexpr != 201606" +#endif + #ifdef __has_cpp_attribute # if ! __has_cpp_attribute(maybe_unused)