OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [plugin/] [self-assign-test-1.C] - Diff between revs 301 and 338

Only display areas with differences | Details | Blame | View Log

Rev 301 Rev 338
// Test the self-assignemnt detection plugin.
// Test the self-assignemnt detection plugin.
// { dg-do compile }
// { dg-do compile }
// { dg-options "-O" }
// { dg-options "-O" }
class Foo {
class Foo {
 private:
 private:
  int a_;
  int a_;
 public:
 public:
  Foo() : a_(a_) {} // { dg-warning "assigned to itself" }
  Foo() : a_(a_) {} // { dg-warning "assigned to itself" }
  void setA(int a) {
  void setA(int a) {
    a_ = a_; // { dg-warning "assigned to itself" }
    a_ = a_; // { dg-warning "assigned to itself" }
  }
  }
  void operator=(Foo& rhs) {
  void operator=(Foo& rhs) {
    this->a_ = rhs.a_;
    this->a_ = rhs.a_;
  }
  }
};
};
struct Bar {
struct Bar {
  int b_;
  int b_;
  int c_;
  int c_;
};
};
int g = g; // { dg-warning "assigned to itself" }
int g = g; // { dg-warning "assigned to itself" }
Foo foo = foo; // { dg-warning "assigned to itself" }
Foo foo = foo; // { dg-warning "assigned to itself" }
int func()
int func()
{
{
  Bar *bar1, bar2;
  Bar *bar1, bar2;
  Foo local_foo;
  Foo local_foo;
  int x = x; // { dg-warning "assigned to itself" }
  int x = x; // { dg-warning "assigned to itself" }
  static int y = y; // { dg-warning "assigned to itself" }
  static int y = y; // { dg-warning "assigned to itself" }
  float *f;
  float *f;
  Bar bar_array[5];
  Bar bar_array[5];
  char n;
  char n;
  int overflow;
  int overflow;
  *f = *f; // { dg-warning "assigned to itself" }
  *f = *f; // { dg-warning "assigned to itself" }
  bar1->b_ = bar1->b_; // { dg-warning "assigned to itself" }
  bar1->b_ = bar1->b_; // { dg-warning "assigned to itself" }
  bar2.c_ = bar2.c_; // { dg-warning "assigned to itself" }
  bar2.c_ = bar2.c_; // { dg-warning "assigned to itself" }
  local_foo = local_foo; // { dg-warning "assigned to itself" }
  local_foo = local_foo; // { dg-warning "assigned to itself" }
  foo = foo; // { dg-warning "assigned to itself" }
  foo = foo; // { dg-warning "assigned to itself" }
  foo.setA(5);
  foo.setA(5);
  bar_array[3].c_ = bar_array[3].c_; // { dg-warning "assigned to itself" }
  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 "self-assignment detected" }
  bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-warning "self-assignment detected" }
  y = x;
  y = x;
  x = y;
  x = y;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.