aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/wself-assign-2.c
blob: d0f69cbafe90dff02712cbe19db659b0777e505f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Test how self-assignment detection handles constant-folding happening */
/*   when parsing the RHS or the initializer.  */
/* { dg-do compile } */
/* { dg-options "-Wself-assign" } */

struct Bar {
  int b_;
  float c_;
};

int g;

int main()
{
  struct Bar *bar;
  int x = x - 0; /* should not warn */
  static int y;
  struct Bar b_array[5];

  b_array[x+g].b_ = b_array[x+g].b_ * 1; /* should no warn */
  g = g + 0; /* should not warn */
  y = y / 1; /* should not warn */
  bar->b_ = bar->b_ - 0; /* should not warn  */
}