2011-03-16 Jason Merrill <jason@redhat.com>
+ PR c++/48089
+ * semantics.c (potential_constant_expression_1): Don't allow *this
+ in a constructor.
+ (register_constexpr_fundef): Use potential_rvalue_constant_expression.
+
PR c++/47301
* decl.c (compute_array_index_type): Don't bother trying to deal
with literal classes in ABI v1.
body = unshare_expr (TREE_OPERAND (body, 0));
}
- if (!potential_constant_expression (body))
+ if (!potential_rvalue_constant_expression (body))
{
DECL_DECLARED_CONSTEXPR_P (fun) = false;
if (!DECL_TEMPLATE_INSTANTIATION (fun))
- require_potential_constant_expression (body);
+ require_potential_rvalue_constant_expression (body);
return NULL;
}
fundef->body = body;
tree x = TREE_OPERAND (t, 0);
STRIP_NOPS (x);
if (is_this_parameter (x))
- return true;
+ {
+ if (DECL_CONSTRUCTOR_P (DECL_CONTEXT (x)) && want_rval)
+ {
+ if (flags & tf_error)
+ error ("the value of the object being constructed is "
+ "not a constant expression");
+ return false;
+ }
+ return true;
+ }
return potential_constant_expression_1 (x, rval, flags);
}
2011-03-16 Jason Merrill <jason@redhat.com>
+ * g++.dg/cpp0x/constexpr-48089.C: New.
+
* g++.dg/cpp0x/constexpr-abi1.C: New.
* g++.dg/cpp0x/constexpr-46336.C: New.