]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/44996 ([C++0x] decltype produces rvalue reference type for parenthesized...
authorJason Merrill <jason@redhat.com>
Tue, 20 Jul 2010 01:31:42 +0000 (21:31 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 20 Jul 2010 01:31:42 +0000 (21:31 -0400)
PR c++/44996
* semantics.c (finish_decltype_type): Correct decltype
of parenthesized rvalue reference variable.

From-SVN: r162323

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype23.C [new file with mode: 0644]

index 9a7c1a4871355a25d37d23a78d3a6d1071020aa3..124fbe2f191ac01c77a06c05c8e79615083d8c86 100644 (file)
@@ -1,5 +1,9 @@
 2010-07-19  Jason Merrill  <jason@redhat.com>
 
+       PR c++/44996
+       * semantics.c (finish_decltype_type): Correct decltype
+       of parenthesized rvalue reference variable.
+
        PR c++/44969
        * tree.c (cp_tree_equal): Compare type of *CAST_EXPR.
        * pt.c (iterative_hash_template_arg): Hash type of *CAST_EXPR.
index a39e0b8dc1f005aa12e46845f57ff1f21925bbf3..949e108902a17570cc3cb5482a475ec8ca548225 100644 (file)
@@ -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);
index e2668148622bb24181fac64da702c2c27ed5ed81..aa5b316305e74788907f113a6932609028807146 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/44996
+       * g++.dg/cpp0x/decltype23.C: New.
+
 2010-07-19  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/42385
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype23.C b/gcc/testsuite/g++.dg/cpp0x/decltype23.C
new file mode 100644 (file)
index 0000000..78eb89d
--- /dev/null
@@ -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;