re PR c++/55425 (constexpr does not work in many situations (both built-in and user...
authorPaolo Carlini <paolo@gcc.gnu.org>
Wed, 19 Nov 2014 17:40:42 +0000 (17:40 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 19 Nov 2014 17:40:42 +0000 (17:40 +0000)
/cp
2014-11-19  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/55425
* constexpr.c (constexpr_fn_retval): Accept __func__, __FUNCTION__,
and __PRETTY_FUNCTION__.

/testsuite
2014-11-19  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/55425
* g++.dg/cpp0x/constexpr-__func__.C

From-SVN: r217788

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-__func__.C [new file with mode: 0644]

index 5769d2af30ed9eaf17229705ea3512dd21e9bd8c..13a9965cee8a5cccad58000e2f1a29d6fb3a17b6 100644 (file)
@@ -1,3 +1,9 @@
+2014-11-19  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/55425
+       * constexpr.c (constexpr_fn_retval): Accept __func__, __FUNCTION__,
+       and __PRETTY_FUNCTION__.
+
 2014-11-18  Jason Merrill  <jason@redhat.com>
 
        PR c++/63924
index 1303fdc4d08a42b438252ef8b3cd29cb7588af4a..d98d9b9259ef18a1e474e91d5ee37747d85f70ae 100644 (file)
@@ -616,9 +616,14 @@ constexpr_fn_retval (tree body)
       return break_out_target_exprs (TREE_OPERAND (body, 0));
 
     case DECL_EXPR:
-      if (TREE_CODE (DECL_EXPR_DECL (body)) == USING_DECL)
-       return NULL_TREE;
-      return error_mark_node;
+      {
+       tree decl = DECL_EXPR_DECL (body);
+       if (TREE_CODE (decl) == USING_DECL
+           /* Accept __func__, __FUNCTION__, and __PRETTY_FUNCTION__.  */
+           || DECL_ARTIFICIAL (decl))
+         return NULL_TREE;
+       return error_mark_node;
+      }
 
     case CLEANUP_POINT_EXPR:
       return constexpr_fn_retval (TREE_OPERAND (body, 0));
index 840a1c14d140b8e57191f3156ff92c8214f79497..3a2dbf7c86a5c4213feccd812e20d9e4fe948916 100644 (file)
@@ -1,11 +1,17 @@
+2014-11-19  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/55425
+       * g++.dg/cpp0x/constexpr-__func__.C
+
 2014-11-19  Renlin Li  <Renlin.Li@arm.com>
-    PR target/63424
+
+       PR target/63424
        * gcc.target/aarch64/pr63424.c: New test.
 
 2014-11-19  Renlin Li  <Renlin.Li@arm.com>
 
-    PR middle-end/63762
-       * gcc.dg/pr63762.c: New test. 
+       PR middle-end/63762
+       * gcc.dg/pr63762.c: New test.
 
 2014-11-19  Marek Polacek  <polacek@redhat.com>
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__.C
new file mode 100644 (file)
index 0000000..a71ed6c
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/55425
+// { dg-do compile { target c++11 } }
+
+constexpr const char* x() { return __func__; }
+constexpr const char* y() { return __FUNCTION__; }
+constexpr const char* z() { return __PRETTY_FUNCTION__; }