diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp index ca82ab084b9..9f7638c8aee 100644 --- a/gdb/testsuite/gdb.cp/casts.exp +++ b/gdb/testsuite/gdb.cp/casts.exp @@ -180,6 +180,9 @@ gdb_test "print (unsigned long long) (LeftRight *) (Right *) &gd == gd_value" \ gdb_test "print (unsigned long long) (LeftRight *) (Right *) r_value == gd_value" \ " = true" +gdb_test "print (const int &) gd.left" \ + " = \\(const int \\&\\) @$nonzero_hex: 23" + gdb_test "print reinterpret_cast(l) == lr_l" " = true" gdb_test "print reinterpret_cast(r) == lr_r" " = true" gdb_test "print reinterpret_cast(lr) == l_lr" " = true" diff --git a/gdb/testsuite/gdb.cp/ref-params.cc b/gdb/testsuite/gdb.cp/ref-params.cc index f038d71fe10..3ef28688607 100644 --- a/gdb/testsuite/gdb.cp/ref-params.cc +++ b/gdb/testsuite/gdb.cp/ref-params.cc @@ -36,6 +36,11 @@ int f2(Child& C) return f1(C); /* Set breakpoint marker2 here. */ } +int f3(const int &i) +{ + return i; +} + struct OtherParent { OtherParent (int other_id0) : other_id(other_id0) { } int other_id; @@ -64,6 +69,7 @@ int main(void) f2(Q); f2(QR); + f3(Q.id); MultiChild MQ(53); MultiChild& MQR = MQ; diff --git a/gdb/testsuite/gdb.cp/ref-params.exp b/gdb/testsuite/gdb.cp/ref-params.exp index 03bb8e62496..e5c28e6e2ad 100644 --- a/gdb/testsuite/gdb.cp/ref-params.exp +++ b/gdb/testsuite/gdb.cp/ref-params.exp @@ -62,3 +62,4 @@ gdb_test "print mf2(MQ)" ".* = 106" gdb_test "print f1(MQR)" ".* = 53" gdb_test "print mf1(MQR)" ".* = 106" gdb_test "print mf2(MQR)" ".* = 106" +gdb_test "print f3(Q.id)" ".* = 42" diff --git a/gdb/valops.c b/gdb/valops.c index 1a943f0fc78..52cce287281 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -411,7 +411,8 @@ value_cast (struct type *type, struct value *arg2) In this case we want to preserve the LVAL of ARG2 as this allows the resulting value to be used in more places. We do this by calling VALUE_COPY if appropriate. */ - if (types_deeply_equal (arg2->type (), type)) + if (types_deeply_equal (make_unqualified_type (arg2->type ()), + make_unqualified_type (type))) { /* If the types are exactly equal then we can avoid creating a new value completely. */