diff options
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/wself-assign-2.c')
-rw-r--r-- | gcc-4.9/gcc/testsuite/gcc.dg/wself-assign-2.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/wself-assign-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/wself-assign-2.c new file mode 100644 index 000000000..d0f69cbaf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/wself-assign-2.c @@ -0,0 +1,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 */ +} |