From 37229a71b0616c3b4dcfa33c4e7c3d23bc57e0ca Mon Sep 17 00:00:00 2001 From: msebor Date: Tue, 26 Apr 2016 22:57:34 +0000 Subject: [PATCH] PR c++/66639 - declare __func__ , __FUNCTION__ & __PRETTY_FUNCTION__ constexpr * g++.dg/cpp1y/func_constexpr.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235458 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/func_constexpr.C | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/func_constexpr.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8401206c7a0..ecd3fa9519f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-04-26 Martin Sebor + + PR c++/66639 + * g++.dg/cpp1y/func_constexpr.C: New test. + 2016-04-26 Patrick Palka PR c++/70241 diff --git a/gcc/testsuite/g++.dg/cpp1y/func_constexpr.C b/gcc/testsuite/g++.dg/cpp1y/func_constexpr.C new file mode 100644 index 00000000000..2edcd01980f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/func_constexpr.C @@ -0,0 +1,29 @@ +// PR c++/66639 - declare __func__ , __FUNCTION__ & __PRETTY_FUNCTION__ +// as constexpr +// { dg-do compile { target c++11 } } + +#define Assert(expr) static_assert ((expr), #expr) +#define Compare(a, b) Assert (0 == __builtin_strcmp (a, b)) + +constexpr const char* func () +{ + return __func__; +} + +constexpr const char* function () +{ + return __FUNCTION__; +} + +constexpr const char* pretty_function () +{ + return __PRETTY_FUNCTION__; +} + +constexpr const char* f0 = func (); +constexpr const char* f1 = function (); +constexpr const char* f2 = pretty_function (); + +Compare (f0, "func"); +Compare (f1, "function"); +Compare (f2, "constexpr const char* pretty_function()"); -- 2.11.4.GIT