+2019-12-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * gdbtypes.h: Define the REFERENCE_SEE_THROUGH_BADNESS value.
+ * gdbtypes.c (rank_one_type): Use REFERENCE_SEE_THROUGH_BADNESS
+ for ranking see-through reference cases.
+
2019-12-06 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* stack.c (faas_command): Check a command is provided.
* thread.c (taas_command, tfaas_command): Likewise.
const struct rank BOOL_CONVERSION_BADNESS = {3,0};
const struct rank BASE_CONVERSION_BADNESS = {2,0};
const struct rank REFERENCE_CONVERSION_BADNESS = {2,0};
+const struct rank REFERENCE_SEE_THROUGH_BADNESS = {0,1};
const struct rank NULL_POINTER_CONVERSION_BADNESS = {2,0};
const struct rank NS_POINTER_CONVERSION_BADNESS = {10,0};
const struct rank NS_INTEGER_POINTER_CONVERSION_BADNESS = {3,0};
if (TYPE_IS_REFERENCE (arg))
return (sum_ranks (rank_one_type (parm, TYPE_TARGET_TYPE (arg), NULL),
- REFERENCE_CONVERSION_BADNESS));
+ REFERENCE_SEE_THROUGH_BADNESS));
if (TYPE_IS_REFERENCE (parm))
return (sum_ranks (rank_one_type (TYPE_TARGET_TYPE (parm), arg, NULL),
- REFERENCE_CONVERSION_BADNESS));
+ REFERENCE_SEE_THROUGH_BADNESS));
if (overload_debug)
/* Debugging only. */
fprintf_filtered (gdb_stderr,
/* * Badness of converting from non-reference to reference. Subrank
is the type of reference conversion being done. */
extern const struct rank REFERENCE_CONVERSION_BADNESS;
+extern const struct rank REFERENCE_SEE_THROUGH_BADNESS;
/* * Conversion to rvalue reference. */
#define REFERENCE_CONVERSION_RVALUE 1
/* * Conversion to const lvalue reference. */
+2019-12-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * gdb.cp/rvalue-ref-overload.cc: Add a case that involves both
+ CV and reference conversion for overload resolution.
+ * gdb.cp/rvalue-ref-overload.exp: Test it.
+
2019-12-06 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.threads/pthreads.exp: Test taas and tfaas without command.
int overload1arg (foo_lval_ref);
int overload1arg (foo_rval_ref);
+ int overloadConst (const foo &);
+ int overloadConst (const foo &&);
};
void
// result = 1 + 2 + 3 + 3 = 9
int result = f (i) + f (ci) + f (0) + f (std::move (i));
+ /* Overload resolution below requires both a CV-conversion
+ and reference conversion. */
+ int test_const // = 3
+ = foo_rr_instance1.overloadConst (arg);
+
marker1 (); // marker1-returns-here
return result;
}
int foo::overload1arg (foo_lval_ref arg) { return 1; }
int foo::overload1arg (foo_rval_ref arg) { return 2; }
+int foo::overloadConst (const foo &arg) { return 3; }
+int foo::overloadConst (const foo &&arg) { return 4; }
{ method public "~foo();" }
{ method public "int overload1arg(foo_lval_ref);" }
{ method public "int overload1arg(foo_rval_ref);" }
+ { method public "int overloadConst(const foo &);" }
+ { method public "int overloadConst(const foo &&);" }
}
gdb_test "print foo_rr_instance1.overload1arg(arg)" \
"\\$\[0-9\]+ = 2" \
"print call overloaded func foo && arg"
+gdb_test "print foo_rr_instance1.overloadConst(arg)" "3"
+
# Test lvalue vs rvalue function overloads
gdb_test "print f (i)" "= 1" "lvalue reference overload"