]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
typeck.c (build_address): Do fold away ADDR_EXPR of INDIRECT_REF.
authorJason Merrill <jason@redhat.com>
Sat, 1 Aug 2009 02:26:13 +0000 (22:26 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 1 Aug 2009 02:26:13 +0000 (22:26 -0400)
* typeck.c (build_address): Do fold away ADDR_EXPR of INDIRECT_REF.
* tree.c (rvalue): Use cp_build_qualified_type, not TYPE_MAIN_VARIANT.

From-SVN: r150324

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/cp/typeck.c

index c52c6da89e1d4ed155f7db0f7ae4fb2b4763a8b8..1f5725140ef49531348848b4c1cfaba0247a61ad 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-31  Jason Merrill  <jason@redhat.com>
+
+       * typeck.c (build_address): Do fold away ADDR_EXPR of INDIRECT_REF.
+       * tree.c (rvalue): Use cp_build_qualified_type, not TYPE_MAIN_VARIANT.
+
 2009-07-29  Jason Merrill  <jason@redhat.com>
 
        PR c++/14912
index 83869c17a1b51e850bf2969c0c95ddea61e7d69a..cbadf0438b66a282eb442297d597e2f67b2fafc3 100644 (file)
@@ -530,7 +530,7 @@ rvalue (tree expr)
      Non-class rvalues always have cv-unqualified types.  */
   type = TREE_TYPE (expr);
   if (!CLASS_TYPE_P (type) && cp_type_quals (type))
-    type = TYPE_MAIN_VARIANT (type);
+    type = cp_build_qualified_type (type, TYPE_UNQUALIFIED);
 
   /* We need to do this for rvalue refs as well to get the right answer
      from decltype; see c++/36628.  */
index 8b684dd795e48c8276afcd7452dd707472307ab2..35c82d637a7b7796aac796ff679634a2a120c814 100644 (file)
@@ -4276,21 +4276,18 @@ condition_conversion (tree expr)
   return t;
 }
 
-/* Return an ADDR_EXPR giving the address of T.  This function
-   attempts no optimizations or simplifications; it is a low-level
-   primitive.  */
+/* Returns the address of T.  This function will fold away
+   ADDR_EXPR of INDIRECT_REF.  */
 
 tree
 build_address (tree t)
 {
-  tree addr;
-
   if (error_operand_p (t) || !cxx_mark_addressable (t))
     return error_mark_node;
-
-  addr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (t)), t);
-
-  return addr;
+  t = build_fold_addr_expr (t);
+  if (TREE_CODE (t) != ADDR_EXPR)
+    t = rvalue (t);
+  return t;
 }
 
 /* Return a NOP_EXPR converting EXPR to TYPE.  */