-
- Downloads
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.
Showing
- gcc/cp/call.cc 38 additions, 6 deletionsgcc/cp/call.cc
- gcc/cp/cp-tree.h 1 addition, 1 deletiongcc/cp/cp-tree.h
- gcc/cp/method.cc 1 addition, 1 deletiongcc/cp/method.cc
- gcc/cp/parser.cc 3 additions, 2 deletionsgcc/cp/parser.cc
- gcc/testsuite/g++.dg/cpp0x/elision4.C 15 additions, 0 deletionsgcc/testsuite/g++.dg/cpp0x/elision4.C
- gcc/testsuite/g++.dg/ext/reference_constructs_from_temporary1.C 1 addition, 1 deletion...stsuite/g++.dg/ext/reference_constructs_from_temporary1.C
- gcc/testsuite/g++.dg/ext/reference_converts_from_temporary1.C 1 addition, 1 deletion...testsuite/g++.dg/ext/reference_converts_from_temporary1.C
Loading
Please register or sign in to comment