diff options
author | Jason Merrill <jason@redhat.com> | 2018-05-23 13:21:39 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-05-23 13:21:39 -0400 |
commit | a347241b939399be041672fa6dfbc6c8c1853e28 (patch) | |
tree | 5bd0c1d1ac2778a2a49fe517118ceedcc7b8c77a /gcc/cp/rtti.c | |
parent | 955da5e5443724cb59f8fbd854c13e78c68bf000 (diff) | |
download | gcc-a347241b939399be041672fa6dfbc6c8c1853e28.zip gcc-a347241b939399be041672fa6dfbc6c8c1853e28.tar.gz gcc-a347241b939399be041672fa6dfbc6c8c1853e28.tar.bz2 |
Fix cast to rvalue reference from prvalue.
* cvt.c (diagnose_ref_binding): Handle rvalue reference.
* rtti.c (build_dynamic_cast_1): Don't try to build a reference to
non-class type. Handle xvalue argument.
* typeck.c (build_reinterpret_cast_1): Allow cast from prvalue to
rvalue reference.
* semantics.c (finish_compound_literal): Do direct-initialization,
not cast, to initialize a reference.
From-SVN: r260622
Diffstat (limited to 'gcc/cp/rtti.c')
-rw-r--r-- | gcc/cp/rtti.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 426a2327..6692fb7 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -616,22 +616,22 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) else { expr = mark_lvalue_use (expr); - - exprtype = build_reference_type (TREE_TYPE (expr)); + exprtype = TREE_TYPE (expr); /* T is a reference type, v shall be an lvalue of a complete class type, and the result is an lvalue of the type referred to by T. */ - - if (! MAYBE_CLASS_TYPE_P (TREE_TYPE (exprtype))) + if (! MAYBE_CLASS_TYPE_P (exprtype)) { errstr = _("source is not of class type"); goto fail; } - if (!COMPLETE_TYPE_P (complete_type (TREE_TYPE (exprtype)))) + if (!COMPLETE_TYPE_P (complete_type (exprtype))) { errstr = _("source is of incomplete class type"); goto fail; } + + exprtype = cp_build_reference_type (exprtype, !lvalue_p (expr)); } /* The dynamic_cast operator shall not cast away constness. */ |