OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [plugin/] [self-assign-test-2.C] - Blame information for rev 399

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
// Test the self-assignemnt detection plugin without checking of operator-eq.
2
// { dg-do compile }
3
// { dg-options "-O -fplugin-arg-selfassign-no-check-operator-eq" }
4
 
5
class Foo {
6
 private:
7
  int a_;
8
 
9
 public:
10
  Foo() : a_(a_) {} // { dg-warning "assigned to itself" }
11
 
12
  void setA(int a) {
13
    a_ = a_; // { dg-warning "assigned to itself" }
14
  }
15
 
16
  void operator=(Foo& rhs) {
17
    this->a_ = rhs.a_;
18
  }
19
};
20
 
21
struct Bar {
22
  int b_;
23
  int c_;
24
};
25
 
26
int g = g; // { dg-warning "assigned to itself" }
27
Foo foo = foo; // { dg-warning "assigned to itself" }
28
 
29
int func()
30
{
31
  Bar *bar1, bar2;
32
  Foo local_foo;
33
  int x = x; // { dg-warning "assigned to itself" }
34
  static int y = y; // { dg-warning "assigned to itself" }
35
  float *f;
36
  Bar bar_array[5];
37
  char n;
38
  int overflow;
39
 
40
  *f = *f; // { dg-warning "assigned to itself" }
41
  bar1->b_ = bar1->b_; // { dg-warning "assigned to itself" }
42
  bar2.c_ = bar2.c_; // { dg-warning "assigned to itself" }
43
  local_foo = local_foo; // { dg-bogus "assigned to itself" }
44
  foo = foo; // { dg-bogus "assigned to itself" }
45
  foo.setA(5);
46
  bar_array[3].c_ = bar_array[3].c_; // { dg-warning "assigned to itself" }
47
  bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-warning "self-assignment detected" }
48
  y = x;
49
  x = y;
50
}

powered by: WebSVN 2.1.0

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