public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Cc: Ville Voutilainen <ville.voutilainen@gmail.com>
Subject: Re: C++ PATCH for C++17 constexpr if
Date: Wed, 10 Aug 2016 22:39:00 -0000	[thread overview]
Message-ID: <CADzB+2n_jDrfd7AQspqcuCb2S7o+koGNGpOGKvuGkmCmUrLAEg@mail.gmail.com> (raw)
In-Reply-To: <CADzB+2nNudHWKqVsTjrxhHuf2gn_ZC=2gHtUtoiGy+EXAxVbWw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

On Wed, Aug 10, 2016 at 5:57 PM, Jason Merrill <jason@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.

[-- Attachment #2: cx-if-macro.diff --]
[-- Type: text/plain, Size: 1231 bytes --]

commit 1f20a739d61ef839ec7091aa1278adf6d726ead4
Author: Jason Merrill <jason@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)

      reply	other threads:[~2016-08-10 22:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-10 21:58 Jason Merrill
2016-08-10 22:39 ` Jason Merrill [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADzB+2n_jDrfd7AQspqcuCb2S7o+koGNGpOGKvuGkmCmUrLAEg@mail.gmail.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ville.voutilainen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).