diff options
author | Marek Polacek <polacek@redhat.com> | 2022-10-05 15:51:30 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2022-10-07 17:18:16 -0400 |
commit | 895dd027d5dda51a95d242aec8a49a6dfa5db58d (patch) | |
tree | 8dd6b92061555471a8c532e2f62a2d03bd17acf6 /gcc/objc | |
parent | f30e9fd33e56a5a721346ea6140722e1b193db42 (diff) | |
download | gcc-895dd027d5dda51a95d242aec8a49a6dfa5db58d.zip gcc-895dd027d5dda51a95d242aec8a49a6dfa5db58d.tar.gz gcc-895dd027d5dda51a95d242aec8a49a6dfa5db58d.tar.bz2 |
c++: fixes for derived-to-base reference binding [PR107085]
This PR reports that
struct Base {};
struct Derived : Base {};
static_assert(__reference_constructs_from_temporary(Base const&, Derived));
doesn't pass, which it should: it's just like
const Base& b(Derived{});
where we bind 'b' to the Base subobject of a temporary object of type
Derived. The ck_base conversion didn't have ->need_temporary_p set because
we didn't need to create a temporary object just for the base, but the whole
object is a temporary so we're still binding to a temporary. Since the
Base subobject is an xvalue, a new function is introduced.
PR c++/107085
gcc/cp/ChangeLog:
* call.cc (conv_binds_ref_to_temporary): New.
(ref_conv_binds_directly): Rename to...
(ref_conv_binds_to_temporary): ...this. Use
conv_binds_ref_to_temporary.
* cp-tree.h (ref_conv_binds_directly): Rename to...
(ref_conv_binds_to_temporary): ...this.
* method.cc (ref_xes_from_temporary): Use ref_conv_binds_to_temporary.
* parser.cc (warn_for_range_copy): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/ext/reference_constructs_from_temporary1.C: Adjust expected
result.
* g++.dg/ext/reference_converts_from_temporary1.C: Likewise.
* g++.dg/cpp0x/elision4.C: New test.
Diffstat (limited to 'gcc/objc')
0 files changed, 0 insertions, 0 deletions