From: Jason Merrill Date: Fri, 5 Aug 2011 19:12:24 +0000 (-0400) Subject: re PR c++/49812 (strange return type for built-in operator++(int, int)) X-Git-Tag: releases/gcc-4.7.0~4601 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9127e99420ca8f238f15c06fe7f9089e38ed862d;p=thirdparty%2Fgcc.git re PR c++/49812 (strange return type for built-in operator++(int, int)) PR c++/49812 * typeck.c (cp_build_unary_op) [POSTINCREMENT_EXPR]: Strip cv-quals. From-SVN: r177479 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d7ad9929c931..46eee7e8dbd8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-08-05 Jason Merrill + PR c++/49812 + * typeck.c (cp_build_unary_op) [POSTINCREMENT_EXPR]: Strip cv-quals. + PR c++/49983 * parser.c (cp_parser_range_for): Only do auto deduction in template if the range is non-dependent. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index ab08eae28590..f53deb985a62 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5220,6 +5220,9 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, } val = boolean_increment (code, arg); } + else if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR) + /* An rvalue has no cv-qualifiers. */ + val = build2 (code, cv_unqualified (TREE_TYPE (arg)), arg, inc); else val = build2 (code, TREE_TYPE (arg), arg, inc); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4956e57e7773..6ba618327bed 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-08-05 Jason Merrill + PR c++/49812 + * g++.dg/overload/rvalue2.C: New. + PR c++/49983 * g++.dg/cpp0x/range-for21.C: New. diff --git a/gcc/testsuite/g++.dg/overload/rvalue2.C b/gcc/testsuite/g++.dg/overload/rvalue2.C new file mode 100644 index 000000000000..8a2290dc2935 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/rvalue2.C @@ -0,0 +1,11 @@ +// PR c++/49812 +// The call should choose the second f because i++ is an int rvalue. + +template void f(const volatile T& t) { t.i; } +template void f(const T&); + +int main() +{ + volatile int i = 0; + f(i++); +}