From: Paolo Carlini Date: Wed, 19 Nov 2014 17:40:42 +0000 (+0000) Subject: re PR c++/55425 (constexpr does not work in many situations (both built-in and user... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0162cb3bb7832f02c355503a04c3d443035bdda4;p=gcc.git re PR c++/55425 (constexpr does not work in many situations (both built-in and user supplied literals)) /cp 2014-11-19 Paolo Carlini PR c++/55425 * constexpr.c (constexpr_fn_retval): Accept __func__, __FUNCTION__, and __PRETTY_FUNCTION__. /testsuite 2014-11-19 Paolo Carlini PR c++/55425 * g++.dg/cpp0x/constexpr-__func__.C From-SVN: r217788 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5769d2af30e..13a9965cee8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-11-19 Paolo Carlini + + PR c++/55425 + * constexpr.c (constexpr_fn_retval): Accept __func__, __FUNCTION__, + and __PRETTY_FUNCTION__. + 2014-11-18 Jason Merrill PR c++/63924 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 1303fdc4d08..d98d9b9259e 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -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)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 840a1c14d14..3a2dbf7c86a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,11 +1,17 @@ +2014-11-19 Paolo Carlini + + PR c++/55425 + * g++.dg/cpp0x/constexpr-__func__.C + 2014-11-19 Renlin Li - PR target/63424 + + PR target/63424 * gcc.target/aarch64/pr63424.c: New test. 2014-11-19 Renlin Li - 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 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__.C new file mode 100644 index 00000000000..a71ed6c63c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__.C @@ -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__; }