From: Jakub Jelinek Date: Thu, 17 Feb 2011 20:44:14 +0000 (+0100) Subject: re PR c++/47783 (Warning 'set but not used' [-Wunused-but-set-parameter] incorrectly... X-Git-Tag: upstream/12.2.0~86337 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3ae330d55dcda25b076d27c043f28d9f9a149fc;p=platform%2Fupstream%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 13de6bd9041..ae368a1e27c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-02-17 Jakub Jelinek + + PR c++/47783 + * cvt.c (convert_from_reference): Call mark_exp_read. + 2011-02-11 Dodji Seketeli PR c++/47172 diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 36c07037a8d..8ab00011432 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 ad376c2bb65..4d6fae0ddd0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-02-17 Jakub Jelinek + + PR c++/47783 + * g++.dg/warn/Wunused-parm-4.C: New test. + 2011-02-17 Alexandre Oliva Jan Hubicka 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 00000000000..fbad380f66c --- /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; +}