re PR c++/55425 (constexpr does not work in many situations (both built-in and user supplied literals))

/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
This commit is contained in:
Paolo Carlini 2014-11-19 17:40:42 +00:00
parent 538dd0b78f
commit 0162cb3bb7
4 changed files with 29 additions and 6 deletions

View 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

View 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));

View 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>

View File

@ -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__; }