On Wed, Mar 8, 2017 at 8:00 PM, Jason Merrill <ja...@redhat.com> wrote: > In this testcase, ctx->object was the array subobject and 'this' > refers to the containing object, so we failed. Fixed by generalizing > PLACEHOLDER_EXPR handling more (in a way that replace_placeholders_r > already handles).
A slight tweak:
commit a1737dce0a808b725f4da93b11c994d90a5878a9 Author: Jason Merrill <ja...@redhat.com> Date: Thu Mar 16 11:57:14 2017 -0400 PR c++/79797 * constexpr.c (lookup_placeholder): Tweak. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 2510e23e..4136b34 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -3832,14 +3832,17 @@ cxx_eval_switch_expr (const constexpr_ctx *ctx, tree t, static tree lookup_placeholder (const constexpr_ctx *ctx, bool lval, tree type) { - if (!ctx || !ctx->ctor || (lval && !ctx->object)) + if (!ctx) return NULL_TREE; /* We could use ctx->object unconditionally, but using ctx->ctor when we can is a minor optimization. */ - if (!lval && same_type_p (TREE_TYPE (ctx->ctor), type)) + if (!lval && ctx->ctor && same_type_p (TREE_TYPE (ctx->ctor), type)) return ctx->ctor; + if (!ctx->object) + return NULL_TREE; + /* Since an object cannot have a field of its own type, we can search outward from ctx->object to find the unique containing object of TYPE. */ tree ob = ctx->object;