diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-23 22:56:04 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-23 22:56:04 +0000 |
commit | d295f848492d151ad1c3a9ed886c7b7ace99cbb9 (patch) | |
tree | e6d0568b16b8369d69bd5a477aa47f3ab6a06469 /gcc/cp/typeck.c | |
parent | b32d1825a6e11676b183faed78316e15fd7c7252 (diff) | |
download | gcc-d295f848492d151ad1c3a9ed886c7b7ace99cbb9.tar.gz |
PR c++/49105
* typeck.c (cp_build_c_cast): Don't strip cv-quals when
converting to reference.
(build_static_cast_1): Update for glvalues.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174093 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r-- | gcc/cp/typeck.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 13b919ca37f..69b25d39645 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5768,11 +5768,11 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, return convert_from_reference (rvalue (cp_fold_convert (type, expr))); } - /* "An lvalue of type cv1 T1 can be cast to type rvalue reference to + /* "A glvalue of type cv1 T1 can be cast to type rvalue reference to cv2 T2 if cv2 T2 is reference-compatible with cv1 T1 (8.5.3)." */ if (TREE_CODE (type) == REFERENCE_TYPE && TYPE_REF_IS_RVALUE (type) - && real_lvalue_p (expr) + && lvalue_or_rvalue_with_address_p (expr) && reference_related_p (TREE_TYPE (type), intype) && (c_cast_p || at_least_as_qualified_p (TREE_TYPE (type), intype))) { @@ -6448,7 +6448,7 @@ cp_build_c_cast (tree type, tree expr, tsubst_flags_t complain) if (!CLASS_TYPE_P (type)) type = TYPE_MAIN_VARIANT (type); result_type = TREE_TYPE (result); - if (!CLASS_TYPE_P (result_type)) + if (!CLASS_TYPE_P (result_type) && TREE_CODE (type) != REFERENCE_TYPE) result_type = TYPE_MAIN_VARIANT (result_type); /* If the type of RESULT does not match TYPE, perform a const_cast to make it match. If the static_cast or |