diff options
author | Jason Merrill <jason@redhat.com> | 2009-08-01 02:26:13 +0000 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2009-08-01 02:26:13 +0000 |
commit | 28639d328458b581f989cc3199d2264f9437778c (patch) | |
tree | 99e6a94266b3834a4322ff190d6b10230426c4a3 | |
parent | 59cbd6c64edc90da34d953a24f70a0d571660b2d (diff) |
* typeck.c (build_address): Do fold away ADDR_EXPR of INDIRECT_REF.
* tree.c (rvalue): Use cp_build_qualified_type, not TYPE_MAIN_VARIANT.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@150324 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/tree.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 15 |
3 files changed, 12 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c52c6da89e1..1f5725140ef 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 83869c17a1b..cbadf0438b6 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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. */ diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 8b684dd795e..35c82d637a7 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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. */ |