int func() { Bar *bar1, bar2; Foo local_foo; int x = x; // { dg-warning "assigned to itself" } static int y = y; // { dg-warning "assigned to itself" } float *f; Bar bar_array[5]; char n; int overflow; *f = *f; // { dg-warning "assigned to itself" } bar1->b_ = bar1->b_; // { dg-warning "assigned to itself" } bar2.c_ = bar2.c_; // { dg-warning "assigned to itself" } local_foo = local_foo; foo = foo; foo.setA(5); bar_array[3].c_ = bar_array[3].c_; // { dg-warning "assigned to itself" } bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-warning "assigned to itself" } y = x; x = y; x += 0; // should not warn y -= 0; // should not warn x /= x; // should not warn y *= y; // should not warn }
int func() { Bar *bar1, bar2; Foo foo; int x = x - 0; // should not warn static int y = y / 1; // should not warn float *f; Bar bar_array[5]; *f = *f / 1; // should not warn bar1->b_ = bar1->b_ * 1; // should not warn bar2.c_ = bar2.c_ - 0; // should not warn foo.setA(5); bar_array[3].c_ = bar_array[3].c_ * 1; // should not warn bar_array[x+g].b_ = bar_array[x+g].b_ / 1; // should not warn x += 0; y -= 0; foo = foo; foo.operator=(foo); // should not warn }
int func() { Bar *bar1, bar2; Foo local_foo; int x = x; // { dg-bogus "assigned to itself" } static int y = y; // { dg-bogus "assigned to itself" } float *f; Bar bar_array[5]; char n; int overflow; *f = *f; // { dg-bogus "assigned to itself" } bar1->b_ = bar1->b_; // { dg-bogus "assigned to itself" } bar2.c_ = bar2.c_; // { dg-bogus "assigned to itself" } local_foo = local_foo; // { dg-bogus "assigned to itself" } foo = foo; // { dg-bogus "assigned to itself" } foo.setA(5); bar_array[3].c_ = bar_array[3].c_; // { dg-bogus "assigned to itself" } bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-bogus "self-assignment detected" } y = x; x = y; }