commit e0f26a1998f2cb404e58bcf8a9f22e29401312e0
Author: Jason Merrill <jason@redhat.com>
Date: Thu Feb 28 11:58:44 2013 -0500
PR c++/56481
* semantics.c (potential_constant_expression_1): Use of 'this' in
a non-constexpr function makes the expression not potentially
constant.
@@ -8497,6 +8497,13 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
STRIP_NOPS (x);
if (is_this_parameter (x))
{
+ if (DECL_CONTEXT (x)
+ && !DECL_DECLARED_CONSTEXPR_P (DECL_CONTEXT (x)))
+ {
+ if (flags & tf_error)
+ error ("use of %<this%> in a constant expression");
+ return false;
+ }
if (want_rval && DECL_CONTEXT (x)
&& DECL_CONSTRUCTOR_P (DECL_CONTEXT (x)))
{