[v6,11/11] Add rvalue reference tests and NEWS entry

Message ID 1489176286-27973-12-git-send-email-keiths@redhat.com
State New, archived
Headers

Commit Message

Keith Seitz March 10, 2017, 8:04 p.m. UTC
  This patch adds tests for the initial rvalue reference support patchset.  All
of the new tests are practically mirrored regular references tests and, except
for the demangler ones, are introduced in new files, which are set to be
compiled with -std=gnu++11.  Tested are printing of rvalue reference types and
values, rvalue reference parameters in function overloading, demangling of
function names containing rvalue reference parameters, casts to rvalue
reference types, application of the sizeof operator to rvalue reference types
and values, and support for rvalue references within the gdb python module.

Changes since v5:
o Added NEWS entries
o Rewrote rvalue-ref-overload.{cc,exp}
o Updated all tests to current coding standard
o Added missing copyright headers, maintaining dates from copied files
o KFAIL failing overload resolution tests

gdb/ChnageLog

	* NEWS: Mention support for ravlue references in GDB and python.

gdb/testsuite/ChangeLog

	PR gdb/14441
	* gdb.cp/rvalue-ref-overload.cc: New file.
	* gdb.cp/rvalue-ref-overload.exp: New file.

	PR gdb/14441
	From Artemiy Volkov  <artemiyv@acm.org>
	* gdb.cp/demangle.exp: Add rvalue reference tests.
	* gdb.cp/rvalue-ref-casts.cc: New file.
	* gdb.cp/rvalue-ref-casts.exp: New file.
	* gdb.cp/rvalue-ref-params.cc: New file.
	* gdb.cp/rvalue-ref-params.exp: New file.
	* gdb.cp/rvalue-ref-sizeof.cc: New file.
	* gdb.cp/rvalue-ref-sizeof.exp: New file.
	* gdb.cp/rvalue-ref-types.cc: New file.
	* gdb.cp/rvalue-ref-types.exp: New file.
	* gdb.python/py-rvalue-ref-value-cc.cc: New file.
	* gdb.python/py-rvalue-ref-value-cc.exp: New file.
---
 gdb/ChangeLog                                      |   5 +
 gdb/NEWS                                           |   3 +
 gdb/testsuite/ChangeLog                            |  20 +++
 gdb/testsuite/gdb.cp/demangle.exp                  |  42 +++++-
 gdb/testsuite/gdb.cp/rvalue-ref-casts.cc           |  75 ++++++++++
 gdb/testsuite/gdb.cp/rvalue-ref-casts.exp          |  76 ++++++++++
 gdb/testsuite/gdb.cp/rvalue-ref-overload.cc        |  86 +++++++++++
 gdb/testsuite/gdb.cp/rvalue-ref-overload.exp       |  69 +++++++++
 gdb/testsuite/gdb.cp/rvalue-ref-params.cc          |  83 +++++++++++
 gdb/testsuite/gdb.cp/rvalue-ref-params.exp         |  64 ++++++++
 gdb/testsuite/gdb.cp/rvalue-ref-sizeof.cc          |  75 ++++++++++
 gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp         |  43 ++++++
 gdb/testsuite/gdb.cp/rvalue-ref-types.cc           |  79 ++++++++++
 gdb/testsuite/gdb.cp/rvalue-ref-types.exp          | 165 +++++++++++++++++++++
 gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc |  59 ++++++++
 .../gdb.python/py-rvalue-ref-value-cc.exp          |  57 +++++++
 16 files changed, 1000 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.cp/rvalue-ref-casts.cc
 create mode 100644 gdb/testsuite/gdb.cp/rvalue-ref-casts.exp
 create mode 100644 gdb/testsuite/gdb.cp/rvalue-ref-overload.cc
 create mode 100644 gdb/testsuite/gdb.cp/rvalue-ref-overload.exp
 create mode 100644 gdb/testsuite/gdb.cp/rvalue-ref-params.cc
 create mode 100644 gdb/testsuite/gdb.cp/rvalue-ref-params.exp
 create mode 100644 gdb/testsuite/gdb.cp/rvalue-ref-sizeof.cc
 create mode 100644 gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp
 create mode 100644 gdb/testsuite/gdb.cp/rvalue-ref-types.cc
 create mode 100644 gdb/testsuite/gdb.cp/rvalue-ref-types.exp
 create mode 100644 gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc
 create mode 100644 gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
  

Comments

Eli Zaretskii March 10, 2017, 10:02 p.m. UTC | #1
> From: Keith Seitz <keiths@redhat.com>
> Date: Fri, 10 Mar 2017 12:04:46 -0800
> 
> diff --git a/gdb/NEWS b/gdb/NEWS
> index cf58595..edbe41f 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -7,9 +7,12 @@
>    added by the Memory Protection Keys for Userspace feature which will be
>    available in future Intel CPUs.
>  
> +* GDB now supports C++11 ravlue references.
                            ^^^^^^
A typo.

(I think it would be nice to have this described in the manual as
well.)

Thanks.
  
Pedro Alves March 13, 2017, 6:52 p.m. UTC | #2
On 03/10/2017 08:04 PM, Keith Seitz wrote:
> This patch adds tests for the initial rvalue reference support patchset.  All
> of the new tests are practically mirrored regular references tests and, except
> for the demangler ones, are introduced in new files, which are set to be
> compiled with -std=gnu++11.  Tested are printing of rvalue reference types and
> values, rvalue reference parameters in function overloading, demangling of
> function names containing rvalue reference parameters, casts to rvalue
> reference types, application of the sizeof operator to rvalue reference types
> and values, and support for rvalue references within the gdb python module.
> 
> Changes since v5:
> o Added NEWS entries
> o Rewrote rvalue-ref-overload.{cc,exp}
> o Updated all tests to current coding standard
> o Added missing copyright headers, maintaining dates from copied files
> o KFAIL failing overload resolution tests

Thanks!

A few nits below.  With these addressed, this is good to me.

> 
> gdb/ChnageLog
> 
> 	* NEWS: Mention support for ravlue references in GDB and python.

Typo, "ravlue".

> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,6 +1,11 @@
>  2017-MM-DD  Keith Seitz  <keiths@redhat.com>
>  
>  	PR gdb/14441
> +	* NEWS: Mention support for ravlue references in GDB and python.

Again.

> +
> +2017-MM-DD  Keith Seitz  <keiths@redhat.com>
> +
> +	PR gdb/14441
>  	From Artemiy Volkov  <artemiyv@acm.org>
>  	* gdbtypes.c (rank_one_type): Implement overloading
>  	resolution rules regarding rvalue references.

> diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-casts.exp b/gdb/testsuite/gdb.cp/rvalue-ref-casts.exp
> new file mode 100644
> index 0000000..7ae4ef0
> --- /dev/null
> +++ b/gdb/testsuite/gdb.cp/rvalue-ref-casts.exp
> @@ -0,0 +1,76 @@
> +# Copyright 2002-2017 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# This file is part of the gdb testsuite
> +
> +# C++11 rvalue reference type casting tests, based on gdb.cp/casts.exp.
> +
> +if {[skip_cplus_tests]} { continue }
> +
> +standard_testfile .cc
> +
> +if {[get_compiler_info "c++"]} {
> +    return -1
> +}
> +
> +if {[prepare_for_testing $testfile.exp $testfile $srcfile \
> +    {debug c++ additional_flags="-std=gnu++11"}]} {
> +    return -1
> +}
> +
> +if {![runto_main]} {
> +    untested "couldn't run to main"
> +    return -1
> +}
> +
> +# Prevent symbol on address 0x0 being printed.
> +gdb_test_no_output "set print symbol off"
> +
> +set line [gdb_get_line_number {rvalue-ref-casts.exp: 1}]
> +gdb_test "break $line" "Breakpoint.*at.* file .*$srcfile, line $line\\."

Please add an explicit test message in order to avoid it changing
if/when $line changes.

> +
> +gdb_test "continue" "Breakpoint .* at .*$srcfile:$line.*"
> +
> +# Check upcasting.
> +gdb_test "print (A &&) br" ".* = .A &&.* {a = 42}" \
> +    "cast derived class rvalue reference to base class rvalue reference"
> +
> +# Check downcasting.
> +gdb_test "print (B &&) ar" ".* = .B.* {<A> = {a = 42}, b = 1729}" \
> +    "cast base class rvalue reference to derived class rvalue reference"
> +
> +# Check compiler casting
> +
> +set nonzero_hex "0x\[0-9A-Fa-f\]\[0-9A-Fa-f\]+"
> +
> +gdb_test "print br" ".* = .B.* {<A> = {a = 42}, b = 1729}" \
> +    [concat "let compiler cast base class rvalue reference to derived " \
> +	 "class rvalue reference"]

Is there a special reason for using concat here?  I'd think a
continuation would do:

	"let compiler cast base class rvalue reference to derived\
	 class rvalue reference"

TCL replaces continuation+newline+spaces/tabs with a single whitespace:
 http://www.tcl.tk/man/tcl8.5/TclCmd/Tcl.htm#M24

> +
> +gdb_test "print static_cast<A &&> (*b)" " = \\(A \\&\\&\\) @$hex: {a = 42}" \
> +    "static_cast to rvalue reference type"
> +
> +gdb_test "print reinterpret_cast<A &&> (*b)" \
> +    " = \\(A \\&\\&\\) @$hex: {a = 42}" \
> +    "reinterpret_cast to rvalue reference type"
> +
> +gdb_test "print dynamic_cast<Alpha &&> (derived)" \
> +    [format " = \\(Alpha \\&\\&\\) @%s: {.* = %s( <vtable for Derived.*>)?}" \
> +	 $nonzero_hex $nonzero_hex] \
> +    "dynamic_cast simple upcast to rvalue reference"
> +
> +gdb_test "print dynamic_cast<VirtuallyDerived &&> (*ad)" \
> +    "dynamic_cast failed" \
> +    "dynamic_cast to rvalue reference to non-existing base"


> new file mode 100644
> index 0000000..7ffb344
> --- /dev/null
> +++ b/gdb/testsuite/gdb.cp/rvalue-ref-params.exp
> @@ -0,0 +1,64 @@
> +# Copyright 2006-2017 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Tests for rvalue reference parameters of types and their subtypes in GDB,
> +# based on gdb.cp/ref-params.exp.
> +
> +#
> +# test running programs
> +#
> +
> +if {[skip_cplus_tests]} { continue }
> +
> +standard_testfile .cc
> +
> +if {[prepare_for_testing $testfile.exp $testfile $srcfile \
> +    {debug c++ additional_flags="-std=gnu++11"}] == 1} {
> +    return -1
> +}
> +
> +proc gdb_start_again {text} {
> +    global binfile
> +    global srcfile
> +
> +    clean_restart $binfile
> +
> +    runto ${srcfile}:[gdb_get_line_number $text]

Should probably be wrapped with with_test_prefix to avoid
duplicate messages from within clean_restart / runto,
in case they fail.

> +}
> +
> +gdb_start_again "marker1 here"
> +gdb_test "print f1(static_cast<Child&&>(Q))" ".* = 40.*" \
> +    "print value of f1 on (Child&&) in main"
> +
> +gdb_start_again "marker1 here"
> +gdb_test "print f2(static_cast<Child&&>(Q))" ".* = 40.*" \
> +    "print value of f2 on (Child&&) in main"
> +
> +gdb_start_again "marker2 here"
> +gdb_test "print C" ".*id = 42.*" "print value of Child&& in f2"
> +
> +setup_kfail "c++/15372" "*-*-*"
> +gdb_test "print f1 (static_cast<Child&&> (C))" ".* = 42.*" \
> +    "print value of f1 on Child&& in f2"
> +
> +gdb_start_again "marker3 here"
> +gdb_test "print R" ".*id = 41.*" "print value of Parent&& in f1"
> +
> +gdb_start_again "breakpoint MQ here"
> +gdb_test "print f1(static_cast<MultiChild&&>(MQ))" ".* = 53"
> +gdb_start_again "breakpoint MQ here"
> +gdb_test "print mf1(static_cast<MultiChild&&>(MQ))" ".* = 106"
> +gdb_start_again "breakpoint MQ here"
> +gdb_test "print mf2(static_cast<MultiChild&&>(MQ))" ".* = 106"


> new file mode 100644
> index 0000000..62a665d
> --- /dev/null
> +++ b/gdb/testsuite/gdb.cp/rvalue-ref-types.cc
> @@ -0,0 +1,79 @@
> +/* This test script is part of GDB, the GNU debugger.
> +
> +   Copyright 1999-2017 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +/* Tests for reference types with short type variables in GDB, based on
> +   gdb.cp/ref-types.cc.  */
> +
> +#include <utility>
> +
> +int main2 ();
> +
> +void
> +marker1 ()
> +{
> +}
> +
> +int
> +main ()
> +{
> +  short t = -1;
> +  short *pt;
> +  short &&rrt = std::move (t);
> +  pt = &rrt;
> +
> +  short *&&rrpt = std::move (pt);
> +  short at[4];
> +  at[0] = 0;
> +  at[1] = 1;
> +  at[2] = 2;
> +  at[3] = 3;
> +
> +  short (&&rrat)[4] = std::move( at);
> +
> +    marker1();
> +
> +    main2();
> +
> +    return 0;

Indentation of these 3 statements above is odd.

> diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-types.exp b/gdb/testsuite/gdb.cp/rvalue-ref-types.exp
> new file mode 100644
> index 0000000..9067b3b
> --- /dev/null
> +++ b/gdb/testsuite/gdb.cp/rvalue-ref-types.exp
> @@ -0,0 +1,165 @@
> +# Copyright 1999-2017 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Tests for reference types with short type variables in GDB, based on
> +# gdb.cp/ref-types.exp.
> +


> +#
> +# test running programs
> +#

Eh, we still have that string blindly copied all over
the place.  Please don't add another copy.  :-)

> +
> +proc gdb_start_again {} {
> +    global srcdir
> +    global subdir
> +    global binfile
> +    global gdb_prompt
> +    global decimal
> +
> +    gdb_start
> +    gdb_reinitialize_dir $srcdir/$subdir
> +    gdb_load ${binfile}
> +
> +    #
> +    # set it up at a breakpoint so we can play with the variable values
> +    #
> +    if {![runto_main]} {
> +	perror "couldn't run to breakpoint"
> +	continue
> +    }
> +
> +    if {![runto 'marker1']} {
> +	perror "couldn't run to marker1"
> +	continue
> +    }
> +
> +    gdb_test "up" ".*main.*" "up from marker1 2"
> +}

Same comment about with_test_prefix.  Actually, can we just
remove the "eof" handling below making this procedure
unnecessary?  (I know this is copied from the other file.)

> +
> +
> +gdb_test_multiple "print rrt" "print value of rrt" {
> +    -re ".\[0-9\]* = \\(short( int)? &&\\) @$hex: -1.*$gdb_prompt $" {
> +        pass "print value of rrt"
> +    }
> +    eof { fail "print rrt ($gdb dumped core) (fixme)" ; gdb_start_again ; }
> +}


Thanks,
Pedro Alves
  
Keith Seitz March 14, 2017, 6:14 p.m. UTC | #3
On 03/10/2017 02:02 PM, Eli Zaretskii wrote:
>> From: Keith Seitz <keiths@redhat.com>
>> Date: Fri, 10 Mar 2017 12:04:46 -0800
>>
>> diff --git a/gdb/NEWS b/gdb/NEWS
>> index cf58595..edbe41f 100644
>> --- a/gdb/NEWS
>> +++ b/gdb/NEWS
>> @@ -7,9 +7,12 @@
>>    added by the Memory Protection Keys for Userspace feature which will be
>>    available in future Intel CPUs.
>>  
>> +* GDB now supports C++11 ravlue references.
>                             ^^^^^^
> A typo.

Good catch. Fixed.

> (I think it would be nice to have this described in the manual as
> well.)

I've searched through the manual for a suitable place to mention this,
the only bit of doc/gdb.texinfo that talks specifically about C++
references is the "reference declarations" in the C++ Expressions node.
I've added a bit explaining that GDB understands both lvalue and rvalue
references.

Let me know if you would like anything further, and thank you for the
quick review!

[I've trimmed down the patch to just the documentation parts. If you
would like to see the full patch, please see my reply to Pedro's message
on this patch.]

Keith

> commit 25826f564b480af57a1da01c0f76c4b61034485e
> Author: Artemiy Volkov <artemiyv@acm.org>
> Date:   Wed Jan 25 10:33:56 2017 -0800
> 
>     Add rvalue reference tests and docs
>     
>     This patch adds tests for the initial rvalue reference support patchset.  All
>     of the new tests are practically mirrored regular references tests and, except
>     for the demangler ones, are introduced in new files, which are set to be
>     compiled with -std=gnu++11.  Tested are printing of rvalue reference types and
>     values, rvalue reference parameters in function overloading, demangling of
>     function names containing rvalue reference parameters, casts to rvalue
>     reference types, application of the sizeof operator to rvalue reference types
>     and values, and support for rvalue references within the gdb python module.
>     
>     gdb/ChnageLog
>     
>     	PR gdb/14441
>     	* NEWS: Mention support for rvalue references in GDB and python.
>     	* doc/gdb.texinfo (C Plus Plus Expressions): Mention that GDB
>     	supports both lvalue and rvalue references.
>     
[snip]
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 544f192..7876b47 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,6 +1,13 @@
>  2017-MM-DD  Artemiy Volkov  <artemiyv@acm.org>
>  
>  	PR gdb/14441
> +	* NEWS: Mention support for rvalue references in GDB and python.
> +	* doc/gdb.texinfo (C Plus Plus Expressions): Mention that GDB
> +	supports both lvalue and rvalue references.
> +
> +2017-MM-DD  Artemiy Volkov  <artemiyv@acm.org>
> +
> +	PR gdb/14441
>  	* gdbtypes.c (rank_one_type): Implement overloading
>  	resolution rules regarding rvalue references.
>  
> diff --git a/gdb/NEWS b/gdb/NEWS
> index cf58595..4fade30 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -7,9 +7,12 @@
>    added by the Memory Protection Keys for Userspace feature which will be
>    available in future Intel CPUs.
>  
> +* GDB now supports C++11 rvalue references.
> +
>  * Python Scripting
>  
>    ** New functions to start, stop and access a running btrace recording.
> +  ** Rvalue references are now supported in gdb.Type.
>  
>  * GDB now supports recording and replaying rdrand and rdseed Intel 64
>    instructions.
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 5cf0f97..581ddae 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -14827,9 +14827,9 @@ see @ref{Completion, ,Command Completion}.
>  
>  @cindex reference declarations
>  @item
> -@value{GDBN} understands variables declared as C@t{++} references; you can use
> -them in expressions just as you do in C@t{++} source---they are automatically
> -dereferenced.
> +@value{GDBN} understands variables declared as C@t{++} lvalue or rvalue
> +references; you can use them in expressions just as you do in C@t{++}
> +source---they are automatically dereferenced.
>
  
Yao Qi April 4, 2017, 11:10 a.m. UTC | #4
Keith Seitz <keiths@redhat.com> writes:

Hi Keith,
> +# Test lvalue vs rvalue function overloads
> +setup_kfail "c++/15372" "*-*-*"
> +gdb_test "print f (i)" "= 1" "lvalue reference overload"
> +

I got KPASS and FAIL in this test.  On x86_64-linux (g++ 5.4.0)

print f (i)^M
$3 = 1^M
(gdb) KPASS: gdb.cp/rvalue-ref-overload.exp: lvalue reference overload
(PRMS c++/15372)

> +gdb_test "print f (ci)" "= 2" "lvalue reference to const overload"
> +

print f (ci)^M
Attempt to take address of value not located in memory.^M
(gdb) FAIL: gdb.cp/rvalue-ref-overload.exp: lvalue reference to const overload

> +setup_kfail "c++/15372" "*-*-*"
> +gdb_test "print f (3)" "= 3" "rvalue reference overload"

They also exist in the test result on aarch64-linux and s390x-linux,
https://gdb-build.sergiodj.net/builders/RHEL-s390x-m64/builds/3700/steps/test%20gdb/logs/stdio
https://gdb-build.sergiodj.net/builders/Ubuntu-AArch64-m64/builds/1666/steps/test%20gdb/logs/stdio
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 338f412..6d9cb4c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,6 +1,11 @@ 
 2017-MM-DD  Keith Seitz  <keiths@redhat.com>
 
 	PR gdb/14441
+	* NEWS: Mention support for ravlue references in GDB and python.
+
+2017-MM-DD  Keith Seitz  <keiths@redhat.com>
+
+	PR gdb/14441
 	From Artemiy Volkov  <artemiyv@acm.org>
 	* gdbtypes.c (rank_one_type): Implement overloading
 	resolution rules regarding rvalue references.
diff --git a/gdb/NEWS b/gdb/NEWS
index cf58595..edbe41f 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -7,9 +7,12 @@ 
   added by the Memory Protection Keys for Userspace feature which will be
   available in future Intel CPUs.
 
+* GDB now supports C++11 ravlue references.
+
 * Python Scripting
 
   ** New functions to start, stop and access a running btrace recording.
+  ** Rvalue references are now supported in gdb.Type.
 
 * GDB now supports recording and replaying rdrand and rdseed Intel 64
   instructions.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 0718d76..6e2a80f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,23 @@ 
+2017-MM-DD  Keith Seitz  <keiths@redhat.com>
+
+	PR gdb/14441
+	Based on work from Artemiy Volkov  <artemiyv@acm.org>
+	* gdb.cp/rvalue-ref-overload.cc: New file.
+	* gdb.cp/rvalue-ref-overload.exp: New file.
+
+	From Artemiy Volkov  <artemiyv@acm.org>
+	* gdb.cp/demangle.exp: Add rvalue reference tests.
+	* gdb.cp/rvalue-ref-casts.cc: New file.
+	* gdb.cp/rvalue-ref-casts.exp: New file.
+	* gdb.cp/rvalue-ref-params.cc: New file.
+	* gdb.cp/rvalue-ref-params.exp: New file.
+	* gdb.cp/rvalue-ref-sizeof.cc: New file.
+	* gdb.cp/rvalue-ref-sizeof.exp: New file.
+	* gdb.cp/rvalue-ref-types.cc: New file.
+	* gdb.cp/rvalue-ref-types.exp: New file.
+	* gdb.python/py-rvalue-ref-value-cc.cc: New file.
+	* gdb.python/py-rvalue-ref-value-cc.exp: New file.
+
 2017-03-10  Keith Seitz  <keiths@redhat.com>
 
 	PR c++/8128
diff --git a/gdb/testsuite/gdb.cp/demangle.exp b/gdb/testsuite/gdb.cp/demangle.exp
index 0ecf95d..fe51c55 100644
--- a/gdb/testsuite/gdb.cp/demangle.exp
+++ b/gdb/testsuite/gdb.cp/demangle.exp
@@ -70,7 +70,9 @@  proc test_demangling_core {tester test result} {
     }
 
     if {[string compare $style $current_demangling_style]} {
-	set_demangling_style $style
+	with_test_prefix $test {
+	    set_demangling_style $style
+	}
     }
 
     $tester "demangle $name" $result $test
@@ -521,6 +523,44 @@  proc test_gnu_style_demangling {} {
     test_demangling_exact "gnu: foo__I_200_" "foo(int512_t)"
     test_demangling_exact "gnu: foo__I_200" "Can't demangle \"foo__I_200\""
 
+    # Rvalue reference tests
+    test_demangling_exact "gnu-v3: _ZN9ArrowLine19ArrowheadIntersectsEP9ArrowheadO6BoxObjP7Graphic" "ArrowLine::ArrowheadIntersects(Arrowhead*, BoxObj&&, Graphic*)"
+    test_demangling "gnu-v3: _Z13BitPatterntoaOK10BitPatternccc" \
+	"BitPatterntoa\[(\]+(const BitPattern|BitPattern const)&&, char, char, char\[)\]+"
+    test_demangling_exact "gnu-v3: _ZN8TextCode14CoreConstDeclsEO7ostream" "TextCode::CoreConstDecls(ostream&&)"
+    test_demangling "gnu-v3: _Z31DrawDestinationTransformedImageP7_XImageiiS0_iimjiijmmP4_XGCOK13ivTransformeriiii" \
+	"DrawDestinationTransformedImage\[(\]+_XImage\[*\]+, int, int, _XImage\[*\]+, int, int, unsigned long, unsigned int, int, int, unsigned int, unsigned long, unsigned long, _XGC\[*\]+, (const ivTransformer|ivTransformer const)&&, int, int, int, int\[)\]+"
+    test_demangling_exact "gnu-v3: _ZN11RelateManip6EffectEO7ivEvent" "RelateManip::Effect(ivEvent&&)"
+    test_demangling_exact "gnu-v3: _ZN20DisplayList_IteratorC4EO11DisplayList" "DisplayList_Iterator::DisplayList_Iterator(DisplayList&&)"
+    test_demangling_exact "gnu-v3: _ZN3fooC4EOS_" "foo::foo(foo&&)"
+    test_demangling_exact "gnu-v3: _ZN3fooC4EiOS_iS0_iS0_" "foo::foo(int, foo&&, int, foo&&, int, foo&&)"
+    test_demangling "gnu-v3: _ZN7ivWorldC2EPKcOiPPcPK12ivOptionDescPK14ivPropertyData" \
+	"ivWorld::ivWorld\[(\]+(const char|char const)\[*\]+, int&&, char\[*\]+\[*\]+, (const ivOptionDesc|ivOptionDesc const)\[*\]+, (const ivPropertyData|ivPropertyData const)\[*\]+\[)\]+"
+    test_demangling "gnu-v3: _Z3argOK7Complex" \
+	"arg\[(\]+(const Complex|Complex const)&&\[)\]+"
+    test_demangling "gnu-v3: _ZNK9BitString8containsEOK10BitPattern" \
+	"BitString::contains\[(\]+(const BitPattern|BitPattern const)&&\[)\]+ const"
+    test_demangling "gnu-v3: _ZNK9BitString8containsEOK12BitSubStringi" \
+	"BitString::contains\[(\]+(const BitSubString|BitSubString const)&&, int\[)\]+ const"
+    test_demangling "gnu-v3: _ZNK9BitString8containsEOKS_" \
+	"BitString::contains\[(\]+(const BitString|BitString const)&&\[)\]+ const"
+    test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityE3PixC4EOKS2_" \
+	"List<VHDLEntity>::Pix::Pix(List<VHDLEntity>::Pix const&&)"
+    test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityE7elementC2EOKS0_PS2_" \
+	"List<VHDLEntity>::element::element(VHDLEntity const&&, List<VHDLEntity>::element*)"
+    test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityE7elementC4EOKS2_" \
+	"List<VHDLEntity>::element::element(List<VHDLEntity>::element const&&)"
+    test_demangling_exact "gnu-v3: _ZNK4ListI10VHDLEntityEclEOKNS1_3PixE" \
+	"List<VHDLEntity>::operator()(List<VHDLEntity>::Pix const&&) const"
+    test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityEC4EOKS1_" \
+	"List<VHDLEntity>::List(List<VHDLEntity> const&&)"
+    test_demangling_exact "gnu-v3: _ZN4PixXI11VHDLLibrary14VHDLLibraryRep4ListI10VHDLEntityEEC2EOKS5_" \
+	"PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > const&&)"
+    test_demangling_exact "gnu-v3: _ZNK11VHDLLibrary5nextEEO4PixXIS_14VHDLLibraryRep4ListI10VHDLEntityEE" \
+	"VHDLLibrary::nextE(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >&&) const"
+    test_demangling_exact "gnu-v3: _ZNK4ListI10VHDLEntityE4nextEONS1_3PixE" \
+	"List<VHDLEntity>::next(List<VHDLEntity>::Pix&&) const"
+
     ## Buffer overrun.  Should make GDB crash.  Woo hoo!
     test_demangling_exact "gnu: foo__I_4000000000000000000000000000000000000000000000000000000000000000000000000" "Can't demangle \"foo__I_4000000000000000000000000000000000000000000000000000000000000000000000000\""
 
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-casts.cc b/gdb/testsuite/gdb.cp/rvalue-ref-casts.cc
new file mode 100644
index 0000000..1f81fe0
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-casts.cc
@@ -0,0 +1,75 @@ 
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2002-2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Rvalue references casting tests, based on casts.cc.  */
+
+#include <utility>
+
+struct A
+{
+  int a;
+  A (int aa): a (aa) {}
+};
+
+struct B: public A
+{
+  int b;
+  B (int aa, int bb): A (aa), b (bb) {}
+};
+
+
+struct Alpha
+{
+  virtual void x () { }
+};
+
+struct Gamma
+{
+};
+
+struct Derived : public Alpha
+{
+};
+
+struct VirtuallyDerived : public virtual Alpha
+{
+};
+
+struct DoublyDerived : public VirtuallyDerived,
+		       public virtual Alpha,
+		       public Gamma
+{
+};
+
+int
+main (int argc, char **argv)
+{
+  A *a = new B (42, 1729);
+  B *b = (B *) a;
+  A &ar = *b;
+  B &br = (B&)ar;
+  A &&arr = std::move (A (42));
+  B &&brr = std::move (B (42, 1729));
+
+  Derived derived;
+  DoublyDerived doublyderived;
+
+  Alpha *ad = &derived;
+  Alpha *add = &doublyderived;
+
+  return 0;  /* breakpoint spot: rvalue-ref-casts.exp: 1 */
+}
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-casts.exp b/gdb/testsuite/gdb.cp/rvalue-ref-casts.exp
new file mode 100644
index 0000000..7ae4ef0
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-casts.exp
@@ -0,0 +1,76 @@ 
+# Copyright 2002-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite
+
+# C++11 rvalue reference type casting tests, based on gdb.cp/casts.exp.
+
+if {[skip_cplus_tests]} { continue }
+
+standard_testfile .cc
+
+if {[get_compiler_info "c++"]} {
+    return -1
+}
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile \
+    {debug c++ additional_flags="-std=gnu++11"}]} {
+    return -1
+}
+
+if {![runto_main]} {
+    untested "couldn't run to main"
+    return -1
+}
+
+# Prevent symbol on address 0x0 being printed.
+gdb_test_no_output "set print symbol off"
+
+set line [gdb_get_line_number {rvalue-ref-casts.exp: 1}]
+gdb_test "break $line" "Breakpoint.*at.* file .*$srcfile, line $line\\."
+
+gdb_test "continue" "Breakpoint .* at .*$srcfile:$line.*"
+
+# Check upcasting.
+gdb_test "print (A &&) br" ".* = .A &&.* {a = 42}" \
+    "cast derived class rvalue reference to base class rvalue reference"
+
+# Check downcasting.
+gdb_test "print (B &&) ar" ".* = .B.* {<A> = {a = 42}, b = 1729}" \
+    "cast base class rvalue reference to derived class rvalue reference"
+
+# Check compiler casting
+
+set nonzero_hex "0x\[0-9A-Fa-f\]\[0-9A-Fa-f\]+"
+
+gdb_test "print br" ".* = .B.* {<A> = {a = 42}, b = 1729}" \
+    [concat "let compiler cast base class rvalue reference to derived " \
+	 "class rvalue reference"]
+
+gdb_test "print static_cast<A &&> (*b)" " = \\(A \\&\\&\\) @$hex: {a = 42}" \
+    "static_cast to rvalue reference type"
+
+gdb_test "print reinterpret_cast<A &&> (*b)" \
+    " = \\(A \\&\\&\\) @$hex: {a = 42}" \
+    "reinterpret_cast to rvalue reference type"
+
+gdb_test "print dynamic_cast<Alpha &&> (derived)" \
+    [format " = \\(Alpha \\&\\&\\) @%s: {.* = %s( <vtable for Derived.*>)?}" \
+	 $nonzero_hex $nonzero_hex] \
+    "dynamic_cast simple upcast to rvalue reference"
+
+gdb_test "print dynamic_cast<VirtuallyDerived &&> (*ad)" \
+    "dynamic_cast failed" \
+    "dynamic_cast to rvalue reference to non-existing base"
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-overload.cc b/gdb/testsuite/gdb.cp/rvalue-ref-overload.cc
new file mode 100644
index 0000000..c12eb03
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-overload.cc
@@ -0,0 +1,86 @@ 
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 1998-2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Rvalue references overload tests for GDB, based on overload.cc.  */
+
+#include <stddef.h>
+#include <utility>
+
+class foo;
+
+typedef foo &foo_lval_ref;
+typedef foo &&foo_rval_ref;
+
+class foo
+{
+public:
+  foo ();
+  foo (foo_lval_ref);
+  foo (foo_rval_ref);
+  ~foo ();
+
+  int overload1arg (foo_lval_ref);
+  int overload1arg (foo_rval_ref);
+};
+
+void
+marker1 ()
+{
+}
+
+static int
+f (int &x)
+{
+  return 1;
+}
+
+static int
+f (const int &x)
+{
+  return 2;
+}
+
+static int
+f (int &&x)
+{
+  return 3;
+}
+
+int
+main ()
+{
+  foo foo_rr_instance1;
+  foo arg;
+  int i = 0;
+  const int ci = 0;
+
+  // result = 1 + 2 + 3 + 3 = 9
+  int result = f (i) + f (ci) + f (0) + f (std::move (i));
+
+  marker1 (); // marker1-returns-here
+  return result;
+}
+
+foo::foo  ()                       {}
+foo::foo  (foo_lval_ref afoo)      {}
+foo::foo  (foo_rval_ref afoo)      {}
+foo::~foo ()                       {}
+
+/* Some functions to test overloading by varying one argument type. */
+
+int foo::overload1arg (foo_lval_ref arg)           { return 1; }
+int foo::overload1arg (foo_rval_ref arg)           { return 2; }
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-overload.exp b/gdb/testsuite/gdb.cp/rvalue-ref-overload.exp
new file mode 100644
index 0000000..e729209
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-overload.exp
@@ -0,0 +1,69 @@ 
+# Copyright 1998-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite
+
+# Tests for overloaded member functions with rvalue reference parameters,
+# based on gdb.cp/overload.exp.
+
+if {[skip_cplus_tests]} { continue }
+
+load_lib "cp-support.exp"
+
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile \
+    {debug c++ additional_flags="-std=gnu++11"}]} {
+    return -1
+}
+
+# Set it up at a breakpoint so we can play with the variable values.
+
+if {![runto 'marker1']} {
+    untested "couldn't run to marker1"
+    return -1
+}
+
+# Prevent symbol on address 0x0 being printed.
+gdb_test_no_output "set print symbol off"
+gdb_test "up" ".*main.*" "up from marker1"
+
+# Print the monster class type.
+cp_test_ptype_class "foo_rr_instance1" "" "class" "foo" \
+    {
+	{ method public "foo(void);" }
+	{ method public "foo(foo_lval_ref);" }
+	{ method public "foo(foo_rval_ref);" }
+	{ method public "~foo();" }
+	{ method public "int overload1arg(foo_lval_ref);" }
+	{ method public "int overload1arg(foo_rval_ref);" }
+    }
+
+gdb_test "print foo_rr_instance1.overload1arg(arg)" \
+    "\\$\[0-9\]+ = 1" \
+    "print call overloaded func foo & arg"
+
+gdb_test "print foo_rr_instance1.overload1arg(static_cast<foo&&>(arg))" \
+    "\\$\[0-9\]+ = 2" \
+    "print call overloaded func foo && arg"
+
+# Test lvalue vs rvalue function overloads
+setup_kfail "c++/15372" "*-*-*"
+gdb_test "print f (i)" "= 1" "lvalue reference overload"
+
+gdb_test "print f (ci)" "= 2" "lvalue reference to const overload"
+
+setup_kfail "c++/15372" "*-*-*"
+gdb_test "print f (3)" "= 3" "rvalue reference overload"
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-params.cc b/gdb/testsuite/gdb.cp/rvalue-ref-params.cc
new file mode 100644
index 0000000..59f459b
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-params.cc
@@ -0,0 +1,83 @@ 
+/* This test script is part of GDB, the GNU debugger.
+
+   Copyright 2006-2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Rvalue reference parameter tests, based on ref-params.cc.  */
+
+#include <utility>
+
+struct Parent
+{
+  Parent (int id0) : id (id0) { }
+  int id;
+};
+
+struct Child : public Parent
+{
+  Child (int id0) : Parent (id0) { }
+};
+
+int
+f1 (Parent &&R)
+{
+  return R.id;			/* Set breakpoint marker3 here.  */
+}
+
+int
+f2 (Child &&C)
+{
+  return f1 (std::move (C));                 /* Set breakpoint marker2 here.  */
+}
+
+struct OtherParent
+{
+  OtherParent (int other_id0) : other_id (other_id0) { }
+  int other_id;
+};
+
+struct MultiChild : public Parent, OtherParent
+{
+  MultiChild (int id0) : Parent (id0), OtherParent (id0 * 2) { }
+};
+
+int
+mf1 (OtherParent &&R)
+{
+  return R.other_id;
+}
+
+int
+mf2 (MultiChild &&C)
+{
+  return mf1 (std::move (C));
+}
+
+int
+main ()
+{
+  Child Q(40);
+  Child &QR = Q;
+
+  /* Set breakpoint marker1 here.  */
+
+  f1 (Child (41));
+  f2 (Child (42));
+
+  MultiChild MQ (53);
+  MultiChild &MQR = MQ;
+
+  mf2 (std::move (MQ));			/* Set breakpoint MQ here.  */
+}
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-params.exp b/gdb/testsuite/gdb.cp/rvalue-ref-params.exp
new file mode 100644
index 0000000..7ffb344
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-params.exp
@@ -0,0 +1,64 @@ 
+# Copyright 2006-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Tests for rvalue reference parameters of types and their subtypes in GDB,
+# based on gdb.cp/ref-params.exp.
+
+#
+# test running programs
+#
+
+if {[skip_cplus_tests]} { continue }
+
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile \
+    {debug c++ additional_flags="-std=gnu++11"}] == 1} {
+    return -1
+}
+
+proc gdb_start_again {text} {
+    global binfile
+    global srcfile
+
+    clean_restart $binfile
+
+    runto ${srcfile}:[gdb_get_line_number $text]
+}
+
+gdb_start_again "marker1 here"
+gdb_test "print f1(static_cast<Child&&>(Q))" ".* = 40.*" \
+    "print value of f1 on (Child&&) in main"
+
+gdb_start_again "marker1 here"
+gdb_test "print f2(static_cast<Child&&>(Q))" ".* = 40.*" \
+    "print value of f2 on (Child&&) in main"
+
+gdb_start_again "marker2 here"
+gdb_test "print C" ".*id = 42.*" "print value of Child&& in f2"
+
+setup_kfail "c++/15372" "*-*-*"
+gdb_test "print f1 (static_cast<Child&&> (C))" ".* = 42.*" \
+    "print value of f1 on Child&& in f2"
+
+gdb_start_again "marker3 here"
+gdb_test "print R" ".*id = 41.*" "print value of Parent&& in f1"
+
+gdb_start_again "breakpoint MQ here"
+gdb_test "print f1(static_cast<MultiChild&&>(MQ))" ".* = 53"
+gdb_start_again "breakpoint MQ here"
+gdb_test "print mf1(static_cast<MultiChild&&>(MQ))" ".* = 106"
+gdb_start_again "breakpoint MQ here"
+gdb_test "print mf2(static_cast<MultiChild&&>(MQ))" ".* = 106"
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.cc b/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.cc
new file mode 100644
index 0000000..ab42c67
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.cc
@@ -0,0 +1,75 @@ 
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2014-2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Sizeof tests for rvalue references, based on cpsizeof.cc.  */
+
+#include <utility>
+
+struct Class
+{
+  int a;
+  char b;
+  long c;
+
+  Class () : a (1), b ('2'), c (3) { }
+};
+
+union Union
+{
+  Class *kp;
+  char a;
+  int b;
+  long c;
+};
+
+enum Enum { A, B, C, D };
+
+typedef unsigned char a4[4];
+typedef unsigned char a8[8];
+typedef unsigned char a12[12];
+typedef Class c4[4];
+typedef Union u8[8];
+typedef Enum e12[12];
+
+#define T(N)					\
+  N N ## obj;					\
+  N&& N ## _rref = std::move (N ## obj);        \
+  N* N ## p = &(N ## obj);			\
+  N*&& N ## p_rref = std::move (N ## p);        \
+  int size_ ## N = sizeof (N ## _rref);		\
+  int size_ ## N ## p = sizeof (N ## p_rref);	\
+
+int
+main ()
+{
+  T (char);
+  T (int);
+  T (long);
+  T (float);
+  T (double);
+  T (a4);
+  T (a8);
+  T (a12);
+  T (Class);
+  T (Union);
+  T (Enum);
+  T (c4);
+  T (u8);
+  T (e12);
+
+  return 0; /* break here */
+}
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp b/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp
new file mode 100644
index 0000000..c6c2d21
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp
@@ -0,0 +1,43 @@ 
+# Copyright 2014-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# sizeof() tests with rvalue reference parameter types, based on
+# gdb.cp/cpsizeof.exp.
+
+standard_testfile .cc
+
+if {[skip_cplus_tests]} { continue }
+
+if {[prepare_for_testing ${testfile}.exp $testfile $srcfile \
+    {debug c++ additional_flags="-std=gnu++11"}] } {
+     return -1
+}
+
+if {![runto_main]} {
+    perror "could not run to main"
+    continue
+}
+
+gdb_breakpoint [gdb_get_line_number "break here"]
+gdb_continue_to_breakpoint "break here"
+
+# Compare sizeof from the compiler and gdb.  Do this once with the actual
+# type name and once with a reference variable.
+foreach v {char int long float double a4 a8 a12 Class Union Enum c4 u8 e12} {
+    gdb_test "print size_$v == sizeof (${v}&&)" "= true"
+    gdb_test "print size_$v == sizeof (${v}_rref)" "= true"
+    gdb_test "print size_${v}p == sizeof (${v}*&&)" "= true"
+    gdb_test "print size_${v}p == sizeof (${v}p_rref)" "= true"
+}
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-types.cc b/gdb/testsuite/gdb.cp/rvalue-ref-types.cc
new file mode 100644
index 0000000..62a665d
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-types.cc
@@ -0,0 +1,79 @@ 
+/* This test script is part of GDB, the GNU debugger.
+
+   Copyright 1999-2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Tests for reference types with short type variables in GDB, based on
+   gdb.cp/ref-types.cc.  */
+
+#include <utility>
+
+int main2 ();
+
+void
+marker1 ()
+{
+}
+
+int
+main ()
+{
+  short t = -1;
+  short *pt;
+  short &&rrt = std::move (t);
+  pt = &rrt;
+
+  short *&&rrpt = std::move (pt);
+  short at[4];
+  at[0] = 0;
+  at[1] = 1;
+  at[2] = 2;
+  at[3] = 3;
+
+  short (&&rrat)[4] = std::move( at);
+
+    marker1();
+
+    main2();
+
+    return 0;
+}
+
+int
+f ()
+{
+  int f1;
+  f1 = 1;
+  return f1;
+}
+
+int
+main2 ()
+{
+  char &&rrC = 'A';
+  unsigned char &&rrUC = 21;
+  short &&rrS = -14;
+  unsigned short &&rrUS = 7;
+  int &&rrI = 102;
+  unsigned int &&rrUI = 1002;
+  long &&rrL = -234;
+  unsigned long &&rrUL = 234;
+  float &&rrF = 1.25E10;
+  double &&rrD = -1.375E-123;
+
+  f ();
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-types.exp b/gdb/testsuite/gdb.cp/rvalue-ref-types.exp
new file mode 100644
index 0000000..9067b3b
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-types.exp
@@ -0,0 +1,165 @@ 
+# Copyright 1999-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Tests for reference types with short type variables in GDB, based on
+# gdb.cp/ref-types.exp.
+
+#
+# test running programs
+#
+
+if { [skip_cplus_tests] } { continue }
+
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile \
+    {debug c++ additional_flags="-std=gnu++11"}]} {
+    return -1
+}
+
+#
+# Set it up at a breakpoint so we can play with the variable values.
+#
+if {![runto_main]} {
+    untested "couldn't run to breakpoint"
+    return -1
+}
+
+if {![runto 'marker1']} {
+    untested "couldn't run to marker1"
+    return -1
+}
+
+gdb_test "up" ".*main.*" "up from marker1 1"
+
+proc gdb_start_again {} {
+    global srcdir
+    global subdir
+    global binfile
+    global gdb_prompt
+    global decimal
+
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load ${binfile}
+
+    #
+    # set it up at a breakpoint so we can play with the variable values
+    #
+    if {![runto_main]} {
+	perror "couldn't run to breakpoint"
+	continue
+    }
+
+    if {![runto 'marker1']} {
+	perror "couldn't run to marker1"
+	continue
+    }
+
+    gdb_test "up" ".*main.*" "up from marker1 2"
+}
+
+
+gdb_test_multiple "print rrt" "print value of rrt" {
+    -re ".\[0-9\]* = \\(short( int)? &&\\) @$hex: -1.*$gdb_prompt $" {
+        pass "print value of rrt"
+    }
+    eof { fail "print rrt ($gdb dumped core) (fixme)" ; gdb_start_again ; }
+}
+
+gdb_test "ptype rrt" "type = short( int)? &&" "ptype rrt"
+
+gdb_test "print *rrpt" ".$decimal = -1" "print value of *rrpt"
+
+# gdb had a bug about dereferencing a pointer type
+# that would lead to wrong results
+# if we try to examine memory at pointer value.
+
+gdb_test "x /hd rrpt" "$hex:\[ \t\]*-1" "examine value at rrpt"
+
+gdb_test "ptype rrpt" "type = short( int)? \\*&&" "ptype rrpt"
+
+gdb_test "print rrat\[0\]" ".$decimal = 0" "print value of rrat\[0\]"
+
+gdb_test "ptype rrat" "type = short( int)? \\\(&&\\\)\\\[4\\\]" "ptype rrat"
+
+gdb_test "print rrat\[1\]" ".$decimal = 1" "print value of rrat\[1\]"
+gdb_test "print rrat\[2\]" ".$decimal = 2" "print value of rrat\[2\]"
+gdb_test "print rrat\[3\]" ".$decimal = 3" "print value of rrat\[3\]"
+
+
+if {![runto 'f']} then {
+    perror "couldn't run to f"
+    continue
+}
+
+gdb_test "up" ".main2.*" "up from f"
+
+gdb_test "ptype rrC" "type = char &&"
+
+gdb_test "ptype rrUC" "type = unsigned char &&"
+
+gdb_test "ptype rrS" "type = short( int)? &&" "ptype rrS"
+
+gdb_test "ptype rrUS" "type = unsigned short( int)? &&" "ptype rrUS"
+
+gdb_test "ptype rrI" "type = int &&"
+
+gdb_test "ptype rrUI" "type = unsigned int &&"
+
+gdb_test "ptype rrL" "type = long( int)? &&" "ptype rrL"
+
+gdb_test "ptype rrUL" "type = unsigned long( int)? &&" "ptype rrUL"
+
+gdb_test "ptype rrF" "type = float &&"
+
+gdb_test "ptype rrD" "type = double &&"
+
+gdb_test "print rrC" "$decimal = \\(char &&\\) @$hex: 65 \'A\'" \
+    "print value of rrC"
+
+gdb_test "print rrUC" \
+    "$decimal = \\(unsigned char &&\\) @$hex: 21 \'.025\'" \
+    "print value of rrUC"
+
+gdb_test "print rrS" "$decimal = \\(short( int)? &&\\) @$hex: -14" \
+                  "print value of rrS"
+
+gdb_test "print rrUS" \
+         "$decimal = \\(unsigned short( int)? &&\\) @$hex: 7" \
+         "print value of rrUS"
+
+gdb_test "print rrI" "$decimal = \\(int &&\\) @$hex: 102" \
+       "print value of rrI"
+
+gdb_test "print rrUI" \
+    "$decimal = \\(unsigned int &&\\) @$hex: 1002" \
+        "print value of rrUI"
+
+gdb_test "print rrL" \
+       "$decimal = \\(long( int)? &&\\) @$hex: -234" \
+         "print value of rrL"
+
+gdb_test "print rrUL" \
+    "$decimal = \\((unsigned long|long unsigned int)? &&\\) @$hex: 234" \
+    "print value of rrUL"
+
+gdb_test "print rrF" \
+    "$decimal = \\(float &&\\) @$hex: 1.2${decimal}e\\+0?10.*" \
+    "print value of rrF"
+
+gdb_test "print rrD" \
+    "$decimal = \\(double &&\\) @$hex: -1.375e-123.*" \
+    "print value of rrD"
diff --git a/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc
new file mode 100644
index 0000000..8943be1
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc
@@ -0,0 +1,59 @@ 
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2012-2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Test rvalue references in python.  Based on py-value-cc.cc.  */
+
+#include <utility>
+
+class A
+{
+public:
+  int operator+ (const int a1);
+
+ public:
+  int a;
+};
+
+int
+A::operator+ (const int a1)
+{
+  return a + a1;
+}
+
+class B : public A
+{
+ public:
+  char a;
+};
+
+typedef int *int_ptr;
+
+int
+main ()
+{
+  int val = 10;
+  int &&int_rref = std::move (val);
+  int_ptr ptr = &val;
+  int_ptr &&int_ptr_rref = std::move (ptr);
+
+  B b;
+  b.a = 'b';
+  (&b)->A::a = 100;
+  B &&b_rref = std::move (b);
+
+  return 0; /* Break here.  */
+}
diff --git a/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
new file mode 100644
index 0000000..dde5a94
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
@@ -0,0 +1,57 @@ 
+# Copyright (C) 2012-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite.  It tests the mechanism
+# exposing rvalue reference values to Python.  It is based on
+# gdb.python/py-value-cc.exp.
+
+if {[skip_cplus_tests]} { continue }
+
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile \
+    {debug c++ additional_flags="-std=c++11"}]} {
+    return -1
+}
+
+# Skip all tests if Python scripting is not enabled.
+if {[skip_python_tests]} { continue }
+
+if {![runto_main]} {
+    untested "couldn't run to main"
+   return -1
+}
+
+gdb_breakpoint [gdb_get_line_number "Break here."]
+gdb_continue_to_breakpoint "Break here" ".*Break here.*"
+
+gdb_test "python print (str(gdb.parse_and_eval(\"int_rref\").type))" "int &&"
+gdb_test "python print (str(gdb.parse_and_eval(\"int_rref\").referenced_value().type))" "int"
+gdb_test "python print (str(gdb.parse_and_eval(\"int_rref\").referenced_value()))" "10"
+
+gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_rref\").dereference().type))" "int"
+gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_rref\").referenced_value().type))" "int_ptr"
+gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_rref\").referenced_value().dereference()))" "10"
+gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_rref\").referenced_value().referenced_value()))" "10"
+
+gdb_test_no_output "python b = gdb.parse_and_eval('b')" "init b"
+gdb_test_no_output "python b_rref = gdb.parse_and_eval('b_rref')" "init b_rref"
+gdb_test_no_output "python b_fields = b.type.fields()" "init b_fields"
+
+gdb_test "python print(b_rref\[b_fields\[1\]\])" "98 'b'" "b_rref.a via field"
+gdb_test "python print(b_rref\[b_fields\[0\]\].type.target())" "A" \
+  "type of b_rref's base class via field"
+gdb_test "python print(b_rref\[b_fields\[0\]\]\['a'\])" "100" \
+  "b_rref.A::a via field"