public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Franklin Mathieu <snaipe@arista.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v1] cxx: Make __func__, __FUNCTION__, and __PRETTY_FUNCTION__ constexpr.
Date: Wed, 28 Jun 2017 12:56:00 -0000	[thread overview]
Message-ID: <CAK8sBDPz_ysOPC7eqHC86v8zTRnHF6uX9U__qFWBHB3gdkuAEw@mail.gmail.com> (raw)
In-Reply-To: <20170628125214.23283-1-snaipe@arista.com>

Sorry about that, please ignore.

On Wed, Jun 28, 2017 at 1:52 PM, Franklin Snaipe Mathieu
<snaipe@arista.com> wrote:
> From: "Franklin \"Snaipe\" Mathieu" <snaipe@diacritic.io>
>
> This patch makes the forementioned definitions `contexpr` when
> compiling C++11 and above with GNU extensions.
>
> gcc/cp/ChangeLog:
> 2017-06-27  Franklin “Snaipe” Mathieu  <snaipe@diacritic.io>
>
>         PR c++/66639
>         * decl.c (cp_make_fname_decl): Make declaration constexpr.
>
> gcc/testsuite/ChangeLog:
> 2017-06-27  Franklin “Snaipe” Mathieu  <snaipe@diacritic.io>
>
>         PR c++/66639
>         * g++.dg/pr66639.c: New test.
> ---
>  gcc/cp/decl.c                  |  5 +++++
>  gcc/testsuite/g++.dg/pr66639.C | 19 +++++++++++++++++++
>  2 files changed, 24 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/pr66639.C
>
> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> index 8e9a466..740ab71 100644
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -4384,6 +4384,11 @@ cp_make_fname_decl (location_t loc, tree id, int type_dep)
>    TREE_READONLY (decl) = 1;
>    DECL_ARTIFICIAL (decl) = 1;
>
> +  /* extension: declare __func__, __FUNCTION__, and __PRETTY_FUNCTION__ as
> +     constexpr.  */
> +  if (!flag_iso && cxx_dialect >= cxx11)
> +    DECL_DECLARED_CONSTEXPR_P (decl) = 1;
> +
>    TREE_USED (decl) = 1;
>
>    if (current_function_decl)
> diff --git a/gcc/testsuite/g++.dg/pr66639.C b/gcc/testsuite/g++.dg/pr66639.C
> new file mode 100644
> index 0000000..51a92f9
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr66639.C
> @@ -0,0 +1,19 @@
> +// PR c++/66639
> +// { dg-do compile { target c++11 } }
> +// { dg-options "" }
> +
> +constexpr bool
> +streq(char const *lhs, char const *rhs)
> +{
> +  return *lhs && *rhs
> +     ? *lhs == *rhs && streq(lhs + 1, rhs + 1)
> +     : !*lhs && !*rhs;
> +}
> +
> +int
> +main()
> +{
> +   static_assert (streq(__func__, "main"), "");
> +   static_assert (streq(__FUNCTION__, "main"), "");
> +   static_assert (streq(__PRETTY_FUNCTION__, "int main()"), "");
> +}
> --
> Franklin "Snaipe" Mathieu
> Arista Networks, Ltd
>



-- 
Franklin "Snaipe" Mathieu

  reply	other threads:[~2017-06-28 12:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-28 12:52 Franklin Snaipe Mathieu
2017-06-28 12:56 ` Franklin Mathieu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-06-28 12:53 Snaipe
2017-06-28 12:57 ` Franklin Mathieu
2017-06-28 12:49 Franklin “Snaipe” Mathieu
2017-06-28 13:06 ` Franklin Mathieu

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=CAK8sBDPz_ysOPC7eqHC86v8zTRnHF6uX9U__qFWBHB3gdkuAEw@mail.gmail.com \
    --to=snaipe@arista.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).