re PR c++/37204 ([c++0x] reinterpret_cast<T&&>(v) incorrectly yields an lvalue)

PR c++/37204
	* typeck.c (build_reinterpret_cast_1): Handle rvalue refs
	properly.

From-SVN: r152661
This commit is contained in:
Jason Merrill 2009-10-12 00:39:04 -04:00 committed by Jason Merrill
parent 420bc2e7aa
commit 45fe7947ed
4 changed files with 28 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2009-10-11 Jason Merrill <jason@redhat.com>
PR c++/37204
* typeck.c (build_reinterpret_cast_1): Handle rvalue refs
properly.
2009-10-11 Richard Guenther <rguenther@suse.de>
* tree.c (cp_free_lang_data): Drop anonymous aggregate names.

View File

@ -5599,12 +5599,17 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p,
intype, type);
expr = cp_build_unary_op (ADDR_EXPR, expr, 0, complain);
if (warn_strict_aliasing > 2)
strict_aliasing_warning (TREE_TYPE (expr), type, expr);
if (expr != error_mark_node)
expr = build_reinterpret_cast_1
(build_pointer_type (TREE_TYPE (type)), expr, c_cast_p,
valid_p, complain);
if (expr != error_mark_node)
expr = cp_build_indirect_ref (expr, 0, complain);
/* cp_build_indirect_ref isn't right for rvalue refs. */
expr = convert_from_reference (fold_convert (type, expr));
return expr;
}

View File

@ -1,3 +1,8 @@
2009-10-11 Jason Merrill <jason@redhat.com>
PR c++/37204
* g++.dg/cpp0x/rv-reinterpret.C: New.
2009-10-11 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/38439

View File

@ -0,0 +1,11 @@
// { dg-options -std=c++0x }
// { dg-do run }
void f(int &);
void f(int &&ir) { ir = 42; }
int main()
{
int x;
f(reinterpret_cast<int&&>(x));
return (x != 42);
}