commit 86aeedbe1a379cf54aac16e068fc8ad8d124ea0b
Author: Jason Merrill <jason@redhat.com>
Date: Mon Jul 19 11:46:37 2010 -0400
PR c++/44996
* semantics.c (finish_decltype_type): Correct decltype
of parenthesized rvalue reference variable.
@@ -4899,8 +4899,9 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p)
type = TYPE_MAIN_VARIANT (type);
else if (real_lvalue_p (expr))
{
- if (TREE_CODE (type) != REFERENCE_TYPE)
- type = build_reference_type (type);
+ if (TREE_CODE (type) != REFERENCE_TYPE
+ || TYPE_REF_IS_RVALUE (type))
+ type = build_reference_type (non_reference (type));
}
else
type = non_reference (type);
new file mode 100644
@@ -0,0 +1,5 @@
+// { dg-options -std=c++0x }
+
+int x, &&y = static_cast<int &&>(x);
+typedef decltype((y)) myInt; // `y' is a parenthesized id-expression of type int that is an lvalue
+typedef int &myInt;