Commit 38295573 by Marek Polacek Committed by Marek Polacek

PR c++/87372 - __func__ constexpr evaluation.

	* constexpr.c (maybe_constant_init_1): Pass false for strict down to
	cxx_eval_outermost_constant_expr.

	* g++.dg/cpp1y/func_constexpr2.C: New test.

From-SVN: r264489
parent edaaef60
2018-09-21 Marek Polacek <polacek@redhat.com>
PR c++/87372 - __func__ constexpr evaluation.
* constexpr.c (maybe_constant_init_1): Pass false for strict down to
cxx_eval_outermost_constant_expr.
2018-09-20 Marek Polacek <polacek@redhat.com>
PR c++/87109 - wrong ctor with maybe-rvalue semantics.
......
......@@ -5364,7 +5364,7 @@ maybe_constant_init_1 (tree t, tree decl, bool allow_non_constant,
/* No evaluation needed. */;
else
t = cxx_eval_outermost_constant_expr (t, allow_non_constant,
!allow_non_constant,
/*strict*/false,
pretend_const_required, decl);
if (TREE_CODE (t) == TARGET_EXPR)
{
......
2018-09-21 Marek Polacek <polacek@redhat.com>
PR c++/87372 - __func__ constexpr evaluation.
* g++.dg/cpp1y/func_constexpr2.C: New test.
2018-09-21 Paul Thomas <pault@gcc.gnu.org>
PR fortran/77325
......
// PR c++/87372
// { dg-do compile { target c++14 } }
constexpr int
foo (char const *s)
{
int i = 0;
while (s[i])
++i;
return i;
}
constexpr int
bar ()
{
constexpr int l = foo (__PRETTY_FUNCTION__);
constexpr int l2 = foo (__FUNCTION__);
constexpr int l3 = foo (__func__);
return l + l2 + l3;
}
static_assert (bar () == 25, "");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment