* 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
+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
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. */
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. */