diff options
Diffstat (limited to 'gcc-4.6/gcc/cp/typeck.c')
-rw-r--r-- | gcc-4.6/gcc/cp/typeck.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc-4.6/gcc/cp/typeck.c b/gcc-4.6/gcc/cp/typeck.c index eaed39067..a8cac768c 100644 --- a/gcc-4.6/gcc/cp/typeck.c +++ b/gcc-4.6/gcc/cp/typeck.c @@ -1299,7 +1299,9 @@ structural_comptypes (tree t1, tree t2, int strict) if (!cp_tree_equal (TYPENAME_TYPE_FULLNAME (t1), TYPENAME_TYPE_FULLNAME (t2))) return false; - if (!same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2))) + /* Qualifiers don't matter on scopes. */ + if (!same_type_ignoring_top_level_qualifiers_p (TYPE_CONTEXT (t1), + TYPE_CONTEXT (t2))) return false; break; @@ -4838,9 +4840,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain) && TREE_CONSTANT (TREE_OPERAND (val, 0))) { tree type = build_pointer_type (argtype); - tree op0 = fold_convert (type, TREE_OPERAND (val, 0)); - tree op1 = fold_convert (sizetype, fold_offsetof (arg, val)); - return fold_build2 (POINTER_PLUS_EXPR, type, op0, op1); + return fold_convert (type, fold_offsetof_1 (arg)); } /* Handle complex lvalues (when permitted) @@ -5775,8 +5775,18 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, && reference_related_p (TREE_TYPE (type), intype) && (c_cast_p || at_least_as_qualified_p (TREE_TYPE (type), intype))) { - expr = build_typed_address (expr, type); - return convert_from_reference (expr); + /* Handle the lvalue case here by casting to lvalue reference and + then changing it to an rvalue reference. Casting an xvalue to + rvalue reference will be handled by the main code path. */ + tree lref = cp_build_reference_type (TREE_TYPE (type), false); + result = (perform_direct_initialization_if_possible + (lref, expr, c_cast_p, complain)); + result = cp_fold_convert (type, result); + /* Make sure we don't fold back down to a named rvalue reference, + because that would be an lvalue. */ + if (DECL_P (result)) + result = build1 (NON_LVALUE_EXPR, type, result); + return convert_from_reference (result); } /* Resolve overloaded address here rather than once in |