2011-03-29 Jason Merrill <jason@redhat.com>
+ PR c++/48089
+ * semantics.c (potential_constant_expression_1): Change error about
+ use of *this in constructor into sorry.
+
PR c++/48296
* decl.c (cp_finish_decl): Defer validation of constexpr member
functions.
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");
+ sorry ("use of the value of the object being constructed "
+ "in a constant expression");
return false;
}
return true;
2011-03-29 Jason Merrill <jason@redhat.com>
+ * g++.dg/cpp0x/constexpr-48089.C: Adjust.
+
* g++.dg/cpp0x/constexpr-memfn1.C: New.
* g++.dg/cpp0x/constexpr-diag1.C: Adjust error locations.
// PR c++/48089
// { dg-options -std=c++0x }
+// bang is ill-formed (diagnostic required) because its initializer is
+// non-constant, because it uses the value of an uninitialized object.
+
+// s() is ill-formed (no diagnostic required) because there is no set of
+// arguments that would produce a constant expression.
+
+// R() is well-formed because i is initialized before j.
+
struct s {
- constexpr s() : v(v) { } // { dg-error "object being constructed" }
- char v;
+ constexpr s() : v(v) { } // { dg-message "" }
+ int v;
+};
+
+constexpr s bang; // { dg-error "" }
+
+struct R {
+ int i,j;
+ constexpr R() : i(42),j(i) { } // { dg-bogus "" "" { xfail *-*-* } }
};
-s bang;
+constexpr R r; // { dg-bogus "" "" { xfail *-*-* } }