Commit a638b034 by Jason Merrill Committed by Jason Merrill

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
parent 6e924e07
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.
......
......@@ -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)
......
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.
......
......@@ -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)
{
......
// 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment