diff options
author | Jakub Jelinek <jakub@redhat.com> | 2011-02-17 21:44:14 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-02-17 21:44:14 +0100 |
commit | e3ae330d55dcda25b076d27c043f28d9f9a149fc (patch) | |
tree | e18b77a0c9dfc6662d8f98605504c231b6eee9b9 | |
parent | a855debfb46ec3e3171b955cfc9c0f4e62dffcf2 (diff) | |
download | gcc-e3ae330d55dcda25b076d27c043f28d9f9a149fc.zip gcc-e3ae330d55dcda25b076d27c043f28d9f9a149fc.tar.gz gcc-e3ae330d55dcda25b076d27c043f28d9f9a149fc.tar.bz2 |
re PR c++/47783 (Warning 'set but not used' [-Wunused-but-set-parameter] incorrectly issued for update through reference wrapper)
PR c++/47783
* cvt.c (convert_from_reference): Call mark_exp_read.
* g++.dg/warn/Wunused-parm-4.C: New test.
From-SVN: r170255
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wunused-parm-4.C | 24 |
4 files changed, 35 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 13de6bd..ae368a1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-02-17 Jakub Jelinek <jakub@redhat.com> + + PR c++/47783 + * cvt.c (convert_from_reference): Call mark_exp_read. + 2011-02-11 Dodji Seketeli <dodji@redhat.com> PR c++/47172 diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 36c0703..8ab0001 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -512,6 +512,7 @@ convert_from_reference (tree val) tree t = TREE_TYPE (TREE_TYPE (val)); tree ref = build1 (INDIRECT_REF, t, val); + mark_exp_read (val); /* We *must* set TREE_READONLY when dereferencing a pointer to const, so that we get the proper error message if the result is used to assign to. Also, &* is supposed to be a no-op. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ad376c2..4d6fae0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-02-17 Jakub Jelinek <jakub@redhat.com> + + PR c++/47783 + * g++.dg/warn/Wunused-parm-4.C: New test. + 2011-02-17 Alexandre Oliva <aoliva@redhat.com> Jan Hubicka <jh@suse.cz> diff --git a/gcc/testsuite/g++.dg/warn/Wunused-parm-4.C b/gcc/testsuite/g++.dg/warn/Wunused-parm-4.C new file mode 100644 index 0000000..fbad380 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-parm-4.C @@ -0,0 +1,24 @@ +// PR c++/47783 +// { dg-do compile } +// { dg-options "-Wunused -W" } + +struct R +{ + int &i; +}; + +void +foo (R r, int &s) +{ + r.i = 7; + s = 8; +} + +int +bar () +{ + int x = 1, y = 1; + R r = { x }; + foo (r, y); + return x + y; +} |