diff options
author | Jason Merrill <jason@redhat.com> | 2009-11-03 13:42:59 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-11-03 13:42:59 -0500 |
commit | a638b034245e39678a9f24b823df0bba0f1453d0 (patch) | |
tree | 716e3fa3e262779057f0f5ce8957916220dfc69f | |
parent | 6e924e079b7f329afe359e91aa4db7856a387bc9 (diff) | |
download | gcc-a638b034245e39678a9f24b823df0bba0f1453d0.zip gcc-a638b034245e39678a9f24b823df0bba0f1453d0.tar.gz gcc-a638b034245e39678a9f24b823df0bba0f1453d0.tar.bz2 |
re PR c++/41815 ([C++0x] GCC wrongly treats rvalues of non-class type cv-qualified)
PR c++/41815
* call.c (build_call_a): Strip cv-quals from rvalue result.
From-SVN: r153862
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/call.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/deduce.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/rv-return.C | 18 |
5 files changed, 29 insertions, 1 deletions
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 <jason@redhat.com> + 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 <jason@redhat.com> + 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<typename T> struct same_type<T, T> {}; int lval_int; int rval_int(); int const lval_const_int=0; -int const rval_const_int(); +int const&& rval_const_int(); template <typename T> 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<typename T, typename U> struct same_type; +template<typename T> struct same_type<T, T> {}; + +int const f() { return 0; } + +int &&r = f(); // binding "int&&" to "int" should succeed +same_type<decltype(f()), int const> s1; +same_type<decltype(0,f()), int> s2; + +template <class T> +T const g() { return 0; } + +int &&r2 = g<int>(); +same_type<decltype(g<int>()), int const> s3; +same_type<decltype(0,g<int>()), int> s4; |