re PR c++/66320 (ICE: in cxx_eval_constant_expression, at cp/constexpr.c:3524)

PR c++/66320
	* constexpr.c (cxx_eval_constant_expression): Treat a placeholder
	with the wrong type as non-constant.

From-SVN: r223901
This commit is contained in:
Jason Merrill 2015-05-31 16:36:18 -04:00 committed by Jason Merrill
parent ce8cddc1b5
commit 6ad6af49da
3 changed files with 32 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2015-05-31 Jason Merrill <jason@redhat.com>
PR c++/66320
* constexpr.c (cxx_eval_constant_expression): Treat a placeholder
with the wrong type as non-constant.
2015-05-27 Jason Merrill <jason@redhat.com>
* decl.c (check_redeclaration_exception_specification): Depend on

View File

@ -3458,7 +3458,9 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
break;
case PLACEHOLDER_EXPR:
if (!ctx || !ctx->ctor || (lval && !ctx->object))
if (!ctx || !ctx->ctor || (lval && !ctx->object)
|| !(same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (t), TREE_TYPE (ctx->ctor))))
{
/* A placeholder without a referent. We can get here when
checking whether NSDMIs are noexcept, or in massage_init_elt;
@ -3473,8 +3475,6 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
use ctx->object unconditionally, but using ctx->ctor when we
can is a minor optimization. */
tree ctor = lval ? ctx->object : ctx->ctor;
gcc_assert (same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (t), TREE_TYPE (ctor)));
return cxx_eval_constant_expression
(ctx, ctor, lval,
non_constant_p, overflow_p);

View File

@ -0,0 +1,23 @@
// PR c++/66320
// { dg-do compile { target c++11 } }
class A
{
virtual int m_fn1 ();
};
class B
{
public:
B (int);
};
class D : B
{
struct C
{
A a;
A b = a;
};
D (int *);
C _channels;
};
D::D (int *) : B (0) {}