aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2016-04-26 22:57:34 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2016-04-26 16:57:34 -0600
commit8ac432938d3c29cc1fd25f8fe33a5dfefd9c2ff6 (patch)
tree2695ce93418db36635974ce84baff639140dc2c4 /gcc
parent843ce8abafc0ba4ff7e15588c9713a784a771f0d (diff)
downloadgcc-8ac432938d3c29cc1fd25f8fe33a5dfefd9c2ff6.zip
gcc-8ac432938d3c29cc1fd25f8fe33a5dfefd9c2ff6.tar.gz
gcc-8ac432938d3c29cc1fd25f8fe33a5dfefd9c2ff6.tar.bz2
PR c++/66639 - declare __func__ , __FUNCTION__ & __PRETTY_FUNCTION__ constexpr
PR c++/66639 - declare __func__ , __FUNCTION__ & __PRETTY_FUNCTION__ constexpr * g++.dg/cpp1y/func_constexpr.C: New test. From-SVN: r235458
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/func_constexpr.C29
2 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8401206..ecd3fa9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..2edcd01
--- /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()");