From 4bbaf9cf22e552ae015cc0a4d75709c416c903f3 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 3 Nov 2009 18:42:59 +0000 Subject: [PATCH] PR c++/41815 * call.c (build_call_a): Strip cv-quals from rvalue result. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153862 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/call.c | 3 +++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/deduce.C | 2 +- gcc/testsuite/g++.dg/cpp0x/rv-return.C | 18 ++++++++++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/rv-return.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1b87b04..a04b6e7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2009-11-03 Jason Merrill + PR c++/41815 + * call.c (build_call_a): Strip cv-quals from rvalue result. + PR c++/40944 * call.c (initialize_reference): Add complain parm. * typeck.c (convert_for_initialization): Pass it. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 674e59d..0979f3a 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -313,6 +313,9 @@ build_call_a (tree function, int n, tree *argarray) gcc_assert (TREE_CODE (fntype) == FUNCTION_TYPE || TREE_CODE (fntype) == METHOD_TYPE); result_type = TREE_TYPE (fntype); + /* An rvalue has no cv-qualifiers. */ + if (SCALAR_TYPE_P (result_type) || VOID_TYPE_P (result_type)) + result_type = cv_unqualified (result_type); if (TREE_CODE (function) == ADDR_EXPR && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8898d92..0371d4a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2009-11-03 Jason Merrill + PR c++/41815 + * g++.dg/cpp0x/rv-return.C: New. + * g++.dg/cpp0x/deduce.C: Adjust. + PR c++/40944 * g++.dg/template/sfinae15.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/deduce.C b/gcc/testsuite/g++.dg/cpp0x/deduce.C index 6bd0516..635228c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/deduce.C +++ b/gcc/testsuite/g++.dg/cpp0x/deduce.C @@ -5,7 +5,7 @@ template struct same_type {}; int lval_int; int rval_int(); int const lval_const_int=0; -int const rval_const_int(); +int const&& rval_const_int(); template void deduce_lval_int(T && t) { diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-return.C b/gcc/testsuite/g++.dg/cpp0x/rv-return.C new file mode 100644 index 0000000..e52101f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-return.C @@ -0,0 +1,18 @@ +// PR c++/41815 +// { dg-options -std=c++0x } + +template struct same_type; +template struct same_type {}; + +int const f() { return 0; } + +int &&r = f(); // binding "int&&" to "int" should succeed +same_type s1; +same_type s2; + +template +T const g() { return 0; } + +int &&r2 = g(); +same_type()), int const> s3; +same_type()), int> s4; -- 2.7.4