]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/66639 - declare __func__ , __FUNCTION__ & __PRETTY_FUNCTION__ constexpr
authorMartin Sebor <msebor@redhat.com>
Tue, 26 Apr 2016 22:57:34 +0000 (22:57 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Tue, 26 Apr 2016 22:57:34 +0000 (16:57 -0600)
PR c++/66639 - declare __func__ , __FUNCTION__ & __PRETTY_FUNCTION__ constexpr
* g++.dg/cpp1y/func_constexpr.C: New test.

From-SVN: r235458

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/func_constexpr.C [new file with mode: 0644]

index 8401206c7a0cd043ade88666b8f806b896a2189d..ecd3fa9519f750af5534bc3e0a30b60b844630ea 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-26  Martin Sebor  <msebor@redhat.com>
+
+       PR c++/66639
+       * g++.dg/cpp1y/func_constexpr.C: New test.
+
 2016-04-26  Patrick Palka  <ppalka@gcc.gnu.org>
 
        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 (file)
index 0000000..2edcd01
--- /dev/null
@@ -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()");