+2011-05-23 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ PR c++/18016
+ * init.c (perform_member_init): Check for self-initialization.
+
2011-05-22 Jason Merrill <jason@redhat.com>
PR c++/48647
if (decl == error_mark_node)
return;
+ if (warn_init_self && init && TREE_CODE (init) == TREE_LIST
+ && TREE_CHAIN (init) == NULL_TREE)
+ {
+ tree val = TREE_VALUE (init);
+ if (TREE_CODE (val) == COMPONENT_REF && TREE_OPERAND (val, 1) == member
+ && TREE_OPERAND (val, 0) == current_class_ref)
+ warning_at (DECL_SOURCE_LOCATION (current_function_decl),
+ OPT_Wuninitialized, "%qD is initialized with itself",
+ member);
+ }
+
if (init == void_type_node)
{
/* mem() means value-initialization. */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -Winit-self" } */
+
+class X {
+ int i;
+ X() : i(i) { } // { dg-warning "initialized with itself" }
+ X(int i) : i(i) { }
+ X(const X& x) : i(x.i) { }
+};
+
+// { dg-prune-output "In constructor" }