This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests


This patch adds tests for the initial rvalue reference support patchset.  Files
to change were selected among the most important files which test regular C++
references and the added tests are practically mirrored regular references
tests. Tested are printing of rvalue reference types and values, rvalue
reference parameters in function overloading, demangling of function names
containing rvalue reference parameters (using the gnu-v3 demangling style since
only the gnu-v3 demangler supports rvalue references), casts to rvalue
reference types, and application of the sizeof operator to rvalue reference
types and values.

All the changed files have been obviously set to compile with -std=c++11,
and in some cases this required altering function names which coincided
with keywords introduced in the new standard.

testsuite/ChangeLog:

2016-01-19  Artemiy Volkov  <artemiyv@acm.org>

        * gdb.cp/casts.cc (main): Change decltype() function name. Add
        rvalue reference type variables.
        * gdb.cp/casts.exp: Compile with -std=c++11. Add rvalue reference
        cast tests.
        * gdb.cp/cpsizeof.cc: Add rvalue reference type variables.
        * gdb.cp/cpsizeof.exp: Compile with -std=c++11. Add rvalue
        reference sizeof tests.
        * gdb.cp/demangle.exp: Add rvalue reference demangle tests.
        * gdb.cp/overload.cc (int main): Add a ctor and some methods
        with rvalue reference parameters.
        * gdb.cp/overload.exp: Compile with -std=c++11. Add rvalue
        reference overloading tests.
        * gdb.cp/ref-params.cc (int f1): New function taking rvalue
        reference parameter.
        (int f2): Likewise.
        (int mf1): Likewise.
        (int mf2): Likewise.
        * gdb.cp/ref-params.exp: Compile with -std=c++11. Add rvalue
        reference parameter printing tests.
        * gdb.cp/ref-types.cc (int main2): Add rvalue reference type
        variables.
        * gdb.cp/ref-types.exp: Compile with -std=c++11. Add rvalue
        reference type printing tests.
---
 gdb/testsuite/gdb.cp/casts.cc       |   8 ++-
 gdb/testsuite/gdb.cp/casts.exp      |  34 +++++++--
 gdb/testsuite/gdb.cp/cpsizeof.cc    |   4 ++
 gdb/testsuite/gdb.cp/cpsizeof.exp   |   2 +-
 gdb/testsuite/gdb.cp/demangle.exp   |  41 ++++++++++-
 gdb/testsuite/gdb.cp/overload.cc    |   9 +++
 gdb/testsuite/gdb.cp/overload.exp   |  14 +++-
 gdb/testsuite/gdb.cp/ref-params.cc  |  29 +++++++-
 gdb/testsuite/gdb.cp/ref-params.exp |  20 +++++-
 gdb/testsuite/gdb.cp/ref-types.cc   |  24 +++++++
 gdb/testsuite/gdb.cp/ref-types.exp  | 136 +++++++++++++++++++++++++++++++++++-
 11 files changed, 307 insertions(+), 14 deletions(-)

diff --git a/gdb/testsuite/gdb.cp/casts.cc b/gdb/testsuite/gdb.cp/casts.cc
index 43f112f..d15fed1 100644
--- a/gdb/testsuite/gdb.cp/casts.cc
+++ b/gdb/testsuite/gdb.cp/casts.cc
@@ -1,3 +1,5 @@
+#include <utility>
+
 struct A
 {
   int a;
@@ -37,7 +39,7 @@ struct DoublyDerived : public VirtuallyDerived,
 // Confuse a simpler approach.
 
 double
-decltype(int x)
+decl_type(int x)
 {
   return x + 2.0;
 }
@@ -49,6 +51,8 @@ main (int argc, char **argv)
   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;
@@ -56,7 +60,7 @@ main (int argc, char **argv)
   Alpha *ad = &derived;
   Alpha *add = &doublyderived;
 
-  double y = decltype(2);
+  double y = decl_type(2);
 
   return 0;  /* breakpoint spot: casts.exp: 1 */
 }
diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp
index 34a2492..086ad74 100644
--- a/gdb/testsuite/gdb.cp/casts.exp
+++ b/gdb/testsuite/gdb.cp/casts.exp
@@ -33,7 +33,7 @@ if [get_compiler_info "c++"] {
     return -1
 }
 
-if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++ additional_flags="-std=c++11"}]} {
     return -1
 }
 
@@ -86,6 +86,18 @@ gdb_test "print (B &) ar" ".* = .B.* {<A> = {a = 42}, b = 1729}" \
 gdb_test "print br" ".* = .B.* {<A> = {a = 42}, b = 1729}" \
     "let compiler cast base class reference to derived class reference"
 
+# Casting Rvalue References.
+# 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
+gdb_test "print br" ".* = .B.* {<A> = {a = 42}, b = 1729}" \
+    "let compiler cast base class rvalue reference to derived class rvalue reference"
 
 # A few basic tests of "new" casts.
 
@@ -101,6 +113,9 @@ gdb_test "print static_cast<A *> (b)" " = \\(A \\*\\) $hex" \
 gdb_test "print static_cast<A &> (*b)" " = \\(A \\&\\) @$hex: {a = 42}" \
     "static_cast to reference type"
 
+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" \
     "basic test of reinterpret_cast"
 
@@ -110,13 +125,16 @@ gdb_test "print reinterpret_cast<void> (b)" "Invalid reinterpret_cast" \
 gdb_test "print reinterpret_cast<A &> (*b)" " = \\(A \\&\\) @$hex: {a = 42}" \
     "reinterpret_cast to reference type"
 
+gdb_test "print reinterpret_cast<A &&> (*b)" " = \\(A \\&\\&\\) @$hex: {a = 42}" \
+    "reinterpret_cast to rvalue reference type"
+
 # Test that keyword shadowing works.
 
-gdb_test "whatis decltype(5)" " = double"
+gdb_test "whatis decl_type(5)" " = double"
 
 # Basic tests using typeof.
 
-foreach opname {__typeof__ __typeof __decltype} {
+foreach opname {__typeof__ __typeof decltype} {
     gdb_test "print (${opname}(a)) (b)" " = \\(A \\*\\) $hex" \
 	"old-style cast using $opname"
 
@@ -127,7 +145,7 @@ foreach opname {__typeof__ __typeof __decltype} {
 	"reinterpret_cast using $opname"
 }
 
-gdb_test "whatis __decltype(*a)" "type = A \\&"
+gdb_test "whatis decltype(*a)" "type = A \\&"
 
 # Tests of dynamic_cast.
 
@@ -153,6 +171,10 @@ gdb_test "print dynamic_cast<Alpha &> (derived)" \
     " = \\(Alpha \\&\\) @$nonzero_hex: {.* = ${nonzero_hex}( <vtable for Derived.*>)?}" \
     "dynamic_cast simple upcast to reference"
 
+gdb_test "print dynamic_cast<Alpha &&> (derived)" \
+    " = \\(Alpha \\&\\&\\) @$nonzero_hex: {.* = ${nonzero_hex}( <vtable for Derived.*>)?}" \
+    "dynamic_cast simple upcast to rvalue reference"
+
 gdb_test "print dynamic_cast<Derived *> (ad)" \
     " = \\(Derived \\*\\) ${nonzero_hex}( <vtable for Derived.*>)?" \
     "dynamic_cast simple downcast"
@@ -169,6 +191,10 @@ gdb_test "print dynamic_cast<VirtuallyDerived &> (*ad)" \
     "dynamic_cast failed" \
     "dynamic_cast to reference to non-existing base"
 
+gdb_test "print dynamic_cast<VirtuallyDerived &&> (*ad)" \
+    "dynamic_cast failed" \
+    "dynamic_cast to rvalue reference to non-existing base"
+
 gdb_test "print dynamic_cast<DoublyDerived *> (add)" \
     " = \\(DoublyDerived \\*\\) ${nonzero_hex}( <vtable for DoublyDerived.*>)?" \
     "dynamic_cast unique downcast"
diff --git a/gdb/testsuite/gdb.cp/cpsizeof.cc b/gdb/testsuite/gdb.cp/cpsizeof.cc
index 2dcaea1..6a8de4a 100644
--- a/gdb/testsuite/gdb.cp/cpsizeof.cc
+++ b/gdb/testsuite/gdb.cp/cpsizeof.cc
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include <utility>
+
 struct Class
 {
   int a;
@@ -44,8 +46,10 @@ typedef Enum e12[12];
 #define T(N)					\
   N N ## obj;					\
   N& N ## _ref = N ## obj;			\
+  N&& N ## _rref = std::move(N ## obj);         \
   N* N ## p = &(N ## obj);			\
   N*& N ## p_ref = N ## p;			\
+  N*&& N ## p_rref = std::move(N ## p);         \
   int size_ ## N = sizeof (N ## _ref);		\
   int size_ ## N ## p = sizeof (N ## p_ref);	\
 
diff --git a/gdb/testsuite/gdb.cp/cpsizeof.exp b/gdb/testsuite/gdb.cp/cpsizeof.exp
index de95c49..18d4db8 100644
--- a/gdb/testsuite/gdb.cp/cpsizeof.exp
+++ b/gdb/testsuite/gdb.cp/cpsizeof.exp
@@ -18,7 +18,7 @@ standard_testfile .cc
 
 if {[skip_cplus_tests]} { continue }
 
-if {[prepare_for_testing ${testfile}.exp $testfile $srcfile {debug c++}] } {
+if {[prepare_for_testing ${testfile}.exp $testfile $srcfile {debug c++ additional_flags="-std=c++11"}] } {
      return -1
 }
 
diff --git a/gdb/testsuite/gdb.cp/demangle.exp b/gdb/testsuite/gdb.cp/demangle.exp
index 96c90db..90d7be6 100644
--- a/gdb/testsuite/gdb.cp/demangle.exp
+++ b/gdb/testsuite/gdb.cp/demangle.exp
@@ -123,20 +123,27 @@ proc test_gnu_style_demangling {} {
     test_demangling "gnu: Append__15NameChooserViewPCc" \
 	"NameChooserView::Append\[(\]+(const char|char const) \[*\]+\[)\]+"
     test_demangling_exact "gnu: ArrowheadIntersects__9ArrowLineP9ArrowheadR6BoxObjP7Graphic" "ArrowLine::ArrowheadIntersects(Arrowhead *, BoxObj &, Graphic *)"
+    test_demangling_exact "gnu-v3: _ZN9ArrowLine19ArrowheadIntersectsEP9ArrowheadO6BoxObjP7Graphic" "ArrowLine::ArrowheadIntersects(Arrowhead*, BoxObj&&, Graphic*)"
     test_demangling_exact "gnu: AtEnd__13ivRubberGroup" "ivRubberGroup::AtEnd(void)"
     test_demangling_exact "gnu: BgFilter__9ivTSolverP12ivInteractor" "ivTSolver::BgFilter(ivInteractor *)"
     test_demangling "gnu: BitPatterntoa__FRC10BitPatternccc" \
 	"BitPatterntoa\[(\]+(const BitPattern|BitPattern const) &, char, char, char\[)\]+"
+    test_demangling "gnu-v3: _Z13BitPatterntoaOK10BitPatternccc" \
+	"BitPatterntoa\[(\]+(const BitPattern|BitPattern const)&&, char, char, char\[)\]+"
     test_demangling_exact "gnu: Check__6UArrayi" "UArray::Check(int)"
     test_demangling_exact "gnu: CoreConstDecls__8TextCodeR7ostream" "TextCode::CoreConstDecls(ostream &)"
+    test_demangling_exact "gnu-v3: _ZN8TextCode14CoreConstDeclsEO7ostream" "TextCode::CoreConstDecls(ostream&&)"
     test_demangling_exact "gnu: Detach__8StateVarP12StateVarView" "StateVar::Detach(StateVarView *)"
     test_demangling_exact "gnu: Done__9ComponentG8Iterator" "Component::Done(Iterator)"
     test_demangling "gnu: DrawDestinationTransformedImage__FP7_XImageiiT0iiUlUiiiUiUlUlP4_XGCRC13ivTransformeriiii" \
 	"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 "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 "gnu: Edit__12StringEditorPCcii" \
 	"StringEditor::Edit\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
     test_demangling_exact "gnu: Effect__11RelateManipR7ivEvent" "RelateManip::Effect(ivEvent &)"
+    test_demangling_exact "gnu-v3: _ZN11RelateManip6EffectEO7ivEvent" "RelateManip::Effect(ivEvent&&)"
     test_demangling "gnu: FilterName__FPCc" \
 	"FilterName\[(\]+(const char|char const) \[*\]+\[)\]+"
     test_demangling "gnu: Filter__6PSTextPCci" \
@@ -206,16 +213,21 @@ proc test_gnu_style_demangling {} {
 	"iv2_6_MenuItem::iv2_6_MenuItem\[(\]+int, (const char|char const) \[*\]+, ivInteractor \[*\]+\[)\]+"
 
     test_demangling_exact "gnu: __20DisplayList_IteratorR11DisplayList" "DisplayList_Iterator::DisplayList_Iterator(DisplayList &)"
+    test_demangling_exact "gnu-v3: _ZN20DisplayList_IteratorC4EO11DisplayList" "DisplayList_Iterator::DisplayList_Iterator(DisplayList&&)"
     test_demangling_exact "gnu: __3fooRT0" "foo::foo(foo &)"
+    test_demangling_exact "gnu-v3: _ZN3fooC4EOS_" "foo::foo(foo&&)"
     test_demangling_exact "gnu: __3fooiN31" "foo::foo(int, int, int, int)"
     test_demangling "gnu: __3fooiPCc" \
 	"foo::foo\[(\]+int, (const char|char const) \[*\]+\[)\]+"
     test_demangling_exact "gnu: __3fooiRT0iT2iT2" "foo::foo(int, foo &, int, foo &, int, foo &)"
+    test_demangling_exact "gnu-v3: _ZN3fooC4EiOS_iS0_iS0_" "foo::foo(int, foo&&, int, foo&&, int, foo&&)"
     test_demangling "gnu: __6GetOptiPPcPCc" \
 	"GetOpt::GetOpt\[(\]+int, char \[*\]+\[*\]+, (const char|char const) \[*\]+\[)\]+"
     test_demangling_exact "gnu: __6KeyMapPT0" "KeyMap::KeyMap(KeyMap *)"
     test_demangling "gnu: __7ivWorldPCcRiPPcPC12ivOptionDescPC14ivPropertyData" \
 	"ivWorld::ivWorld\[(\]+(const char|char const) \[*\]+, int &, char \[*\]+\[*\]+, (const ivOptionDesc|ivOptionDesc const) \[*\]+, (const ivPropertyData|ivPropertyData const) \[*\]+\[)\]+"
+    test_demangling "gnu-v3: _ZN7ivWorldC2EPKcOiPPcPK12ivOptionDescPK14ivPropertyData" \
+	"ivWorld::ivWorld\[(\]+(const char|char const)\[*\]+, int&&, char\[*\]+\[*\]+, (const ivOptionDesc|ivOptionDesc const)\[*\]+, (const ivPropertyData|ivPropertyData const)\[*\]+\[)\]+"
     test_demangling "gnu: __7procbufPCci" \
 	"procbuf::procbuf\[(\]+(const char|char const) \[*\]+, int\[)\]+"
     test_demangling_exact "gnu: __8ArrowCmdP6EditorUiUi" "ArrowCmd::ArrowCmd(Editor *, unsigned int, unsigned int)"
@@ -295,6 +307,8 @@ proc test_gnu_style_demangling {} {
     test_demangling_exact "gnu: append__7ivGlyphPT0" "ivGlyph::append(ivGlyph *)"
     test_demangling "gnu: arg__FRC7Complex" \
 	"arg\[(\]+(const Complex|Complex const) &\[)\]+"
+    test_demangling "gnu-v3: _Z3argOK7Complex" \
+	"arg\[(\]+(const Complex|Complex const)&&\[)\]+"
     test_demangling_exact "gnu: clearok__FP7_win_sti" "clearok(_win_st *, int)"
 
     test_demangling_exact "gnu: complexfunc2__FPFPc_i" "complexfunc2(int (*)(char *))"
@@ -305,10 +319,16 @@ proc test_gnu_style_demangling {} {
     test_demangling_exact "gnu: complexfunc7__FPFPFPc_i_PFl_i" "complexfunc7(int (*(*)(int (*)(char *)))(long))"
     test_demangling "gnu: contains__C9BitStringRC10BitPattern" \
 	"BitString::contains\[(\]+(const BitPattern|BitPattern const) &\[)\]+ const"
+    test_demangling "gnu-v3: _ZNK9BitString8containsEOK10BitPattern" \
+	"BitString::contains\[(\]+(const BitPattern|BitPattern const)&&\[)\]+ const"
     test_demangling "gnu: contains__C9BitStringRC12BitSubStringi" \
 	"BitString::contains\[(\]+(const BitSubString|BitSubString const) &, int\[)\]+ const"
+    test_demangling "gnu-v3: _ZNK9BitString8containsEOK12BitSubStringi" \
+	"BitString::contains\[(\]+(const BitSubString|BitSubString const)&&, int\[)\]+ const"
     test_demangling "gnu: contains__C9BitStringRT0" \
 	"BitString::contains\[(\]+(const BitString|BitString const) &\[)\]+ const"
+    test_demangling "gnu-v3: _ZNK9BitString8containsEOKS_" \
+	"BitString::contains\[(\]+(const BitString|BitString const)&&\[)\]+ const"
     test_demangling "gnu: div__FPC6IntRepT0P6IntRep" \
 	"div\[(\]+(const IntRep|IntRep const) \[*\]+, (const IntRep|IntRep const) \[*\]+, IntRep \[*\]+\[)\]+"
     test_demangling "gnu: div__FPC6IntReplP6IntRep" \
@@ -436,18 +456,26 @@ proc test_gnu_style_demangling {} {
 
     test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity3PixRCQ2t4List1Z10VHDLEntity3Pix" \
 	"List<VHDLEntity>::Pix::Pix(List<VHDLEntity>::Pix const &)"
+    test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityE3PixC4EOKS2_" \
+	"List<VHDLEntity>::Pix::Pix(List<VHDLEntity>::Pix const&&)"
 
     test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity7elementRC10VHDLEntityPT0" \
 	"List<VHDLEntity>::element::element(VHDLEntity const &, List<VHDLEntity>::element *)"
+    test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityE7elementC2EOKS0_PS2_" \
+	"List<VHDLEntity>::element::element(VHDLEntity const&&, List<VHDLEntity>::element*)"
 
     test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity7elementRCQ2t4List1Z10VHDLEntity7element" \
 	"List<VHDLEntity>::element::element(List<VHDLEntity>::element const &)"
+    test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityE7elementC4EOKS2_" \
+	"List<VHDLEntity>::element::element(List<VHDLEntity>::element const&&)"
 
     test_demangling_exact "gnu: __cl__C11VHDLLibraryGt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
 	"VHDLLibrary::operator()(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >) const"
 
     test_demangling_exact "gnu: __cl__Ct4List1Z10VHDLEntityRCQ2t4List1Z10VHDLEntity3Pix" \
 	"List<VHDLEntity>::operator()(List<VHDLEntity>::Pix const &) const"
+    test_demangling_exact "gnu-v3: _ZNK4ListI10VHDLEntityEclEOKNS1_3PixE" \
+	"List<VHDLEntity>::operator()(List<VHDLEntity>::Pix const&&) const"
 
     test_demangling_exact "gnu: __ne__FPvRCQ2t4List1Z10VHDLEntity3Pix" \
 	"operator!=(void *, List<VHDLEntity>::Pix const &)"
@@ -457,6 +485,8 @@ proc test_gnu_style_demangling {} {
 
     test_demangling_exact "gnu: __t4List1Z10VHDLEntityRCt4List1Z10VHDLEntity" \
 	"List<VHDLEntity>::List(List<VHDLEntity> const &)"
+    test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityEC4EOKS1_" \
+	"List<VHDLEntity>::List(List<VHDLEntity> const&&)"
 
     test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
 	"PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(void)"
@@ -465,13 +495,19 @@ proc test_gnu_style_demangling {} {
 	"PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(VHDLLibraryRep *, List<VHDLEntity>::Pix)"
 
     test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
-	"PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > const &)"
+       "PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(PixX<VHDLLibrary, VHDLLibraryRep, 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: nextE__C11VHDLLibraryRt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
 	"VHDLLibrary::nextE(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: next__Ct4List1Z10VHDLEntityRQ2t4List1Z10VHDLEntity3Pix" \
 	"List<VHDLEntity>::next(List<VHDLEntity>::Pix &) const"
+    test_demangling_exact "gnu-v3: _ZNK4ListI10VHDLEntityE4nextEONS1_3PixE" \
+	"List<VHDLEntity>::next(List<VHDLEntity>::Pix&&) const"
 
     test_demangling_exact "gnu: _GLOBAL_\$D\$set" "global destructors keyed to set"
 
@@ -511,7 +547,6 @@ proc test_gnu_style_demangling {} {
 	"operator!=(void *, BDDFunction::VixB const &)"
     test_demangling_exact "gnu: __eq__FPvRCQ211BDDFunction4VixB" \
 	"operator==(void *, BDDFunction::VixB const &)"
-
     test_demangling_exact "gnu: relativeId__CQ36T_phi210T_preserve8FPC_nextRCQ26T_phi210T_preserveRC10Parameters" \
 	 "T_phi2::T_preserve::FPC_next::relativeId(T_phi2::T_preserve const &, Parameters const &) const"
 
@@ -535,6 +570,7 @@ proc test_gnu_style_demangling {} {
 	    pass "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator"
 	}
     }
+
 }
 
 #
@@ -1489,6 +1525,7 @@ proc test_hp_style_demangling {} {
     test_demangling_exact "hp: elem__6vectorXTiSN67TRdTFPv_i__Fi" "vector<int,-67,double &,int (void *)>::elem(int)"
     test_demangling_exact "hp: X__6vectorXTiSN67TdTPvUP5TRs" "vector<int,-67,double,void *,5U,short &>::X"
 
+
     # Named constants in template args
 
     test_demangling_exact "hp: elem__6vectorXTiA3foo__Fi" "vector<int,&foo>::elem(int)"
diff --git a/gdb/testsuite/gdb.cp/overload.cc b/gdb/testsuite/gdb.cp/overload.cc
index 5c782a4..a977c43 100644
--- a/gdb/testsuite/gdb.cp/overload.cc
+++ b/gdb/testsuite/gdb.cp/overload.cc
@@ -1,10 +1,12 @@
 #include <stddef.h>
+#include <utility>
 
 class foo {
 public:
   foo  (int);
   foo  (int, const char *);
   foo  (foo&);
+  foo  (foo&&);
   ~foo ();
   void foofunc (int);
   void foofunc (int, signed char *);
@@ -27,6 +29,9 @@ int overload1arg (double);
 int overload1arg (int*);
 int overload1arg (void*);
 
+int overload1arg (foo &);
+int overload1arg (foo &&);
+
 int overloadfnarg (void);
 int overloadfnarg (int);
 int overloadfnarg (int, int (*) (int));
@@ -114,6 +119,7 @@ int main ()
     double arg12 = 200.0;
     int arg13 = 200;
     char arg14 = 'a';
+    foo arg15(5);
 
     A a;
     B b;
@@ -153,6 +159,7 @@ int main ()
 foo::foo  (int i)                  { ifoo = i; ccpfoo = NULL; }
 foo::foo  (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; }
 foo::foo  (foo& afoo)              { ifoo = afoo.ifoo; ccpfoo = afoo.ccpfoo;}
+foo::foo  (foo&& afoo)             { ifoo = std::move(afoo.ifoo); ccpfoo = std::move (afoo.ccpfoo); }
 foo::~foo ()                       {}
 
 
@@ -172,6 +179,8 @@ int foo::overload1arg (float arg)           { arg = 0; return 11;}
 int foo::overload1arg (double arg)          { arg = 0; return 12;}
 int foo::overload1arg (int* arg)            { arg = 0; return 13;}
 int foo::overload1arg (void* arg)           { arg = 0; return 14;}
+int foo::overload1arg (foo &arg)            { return 15; }
+int foo::overload1arg (foo &&arg)           { return 16; }
 
 /* Test to see that we can explicitly request overloaded functions
    with function pointers in the prototype. */
diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp
index 0cfa638..cfe7f90 100644
--- a/gdb/testsuite/gdb.cp/overload.exp
+++ b/gdb/testsuite/gdb.cp/overload.exp
@@ -28,7 +28,7 @@ if { [skip_cplus_tests] } { continue }
 
 standard_testfile .cc
 
-if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++ additional_flags="-std=c++11"}]} {
     return -1
 }
 
@@ -53,7 +53,7 @@ gdb_test "up" ".*main.*" "up from marker1"
 set re_class	"((struct|class) foo \{${ws}public:|struct foo \{)"
 set re_fields	"int ifoo;${ws}const char ?\\* ?ccpfoo;"
 set XX_fields  	"int ifoo;${ws}char ?\\* ?ccpfoo;"
-set re_ctor	"foo\\(int\\);${ws}foo\\(int, (char const|const char) ?\\*\\);${ws}foo\\(foo ?&\\);"
+set re_ctor	"foo\\(int\\);${ws}foo\\(int, (char const|const char) ?\\*\\);${ws}foo\\(foo ?&\\);${ws}foo\\(foo ?&?&\\);"
 set re_dtor	"~foo\\((void|)\\);"
 set XX_dtor	"~foo\\(int\\);"
 set re_methods	                  "void foofunc\\(int\\);"
@@ -72,6 +72,8 @@ set re_methods	"${re_methods}${ws}int overload1arg\\(float\\);"
 set re_methods	"${re_methods}${ws}int overload1arg\\(double\\);"
 set re_methods	"${re_methods}${ws}int overload1arg\\(int \\*\\);"
 set re_methods	"${re_methods}${ws}int overload1arg\\(void \\*\\);"
+set re_methods  "${re_methods}${ws}int overload1arg\\(foo &\\);"
+set re_methods  "${re_methods}${ws}int overload1arg\\(foo &&\\);"
 set re_methods	"${re_methods}${ws}int overloadfnarg\\((void|)\\);"
 set re_methods	"${re_methods}${ws}int overloadfnarg\\(int\\);"
 set re_methods	"${re_methods}${ws}int overloadfnarg\\(int, int ?\\(\\*\\) ?\\(int\\)\\);"
@@ -254,6 +256,14 @@ gdb_test "print foo_instance1.overload1arg(&arg14)" \
     "\\$\[0-9\]+ = 14" \
     "print call overloaded func char\\* arg"
 
+gdb_test "print foo_instance1.overload1arg(arg15)" \
+    "\\$\[0-9\]+ = 15" \
+    "print call overloaded func foo & arg"
+
+gdb_test "print foo_instance1.overload1arg(static_cast<foo&&>(arg15))" \
+    "\\$\[0-9\]+ = 16" \
+    "print call overloaded func foo && arg"
+
 gdb_test "print bar(a)" "= 11"
 gdb_test "print bar(b)" "= 22"
 gdb_test "print bar(c)" "= 22"
diff --git a/gdb/testsuite/gdb.cp/ref-params.cc b/gdb/testsuite/gdb.cp/ref-params.cc
index 0f7e125..efced2e 100644
--- a/gdb/testsuite/gdb.cp/ref-params.cc
+++ b/gdb/testsuite/gdb.cp/ref-params.cc
@@ -17,6 +17,8 @@
 
 /* Author: Paul N. Hilfinger, AdaCore Inc. */
 
+#include <utility>
+
 struct Parent {
   Parent (int id0) : id(id0) { }
   int id;
@@ -28,7 +30,12 @@ struct Child : public Parent {
 
 int f1(Parent& R)
 {
-  return R.id;			/* Set breakpoint marker3 here.  */
+  return R.id;			/* Set breakpoint marker4 here.  */
+}
+
+int f1(Parent&& R)
+{
+  return R.id;			/* Set breakpoint marker5 here.  */
 }
 
 int f2(Child& C)
@@ -36,6 +43,11 @@ int f2(Child& C)
   return f1(C);			/* Set breakpoint marker2 here.  */
 }
 
+int f2(Child&& C)
+{
+  return f1(std::move(C));                 /* Set breakpoint marker3 here.  */
+}
+
 struct OtherParent {
   OtherParent (int other_id0) : other_id(other_id0) { }
   int other_id;
@@ -50,11 +62,21 @@ int mf1(OtherParent& R)
   return R.other_id;
 }
 
+int mf1(OtherParent&& R)
+{
+  return R.other_id;
+}
+
 int mf2(MultiChild& C)
 {
   return mf1(C);
 }
 
+int mf2(MultiChild&& C)
+{
+  return mf1(C);
+}
+
 int main(void) 
 {
   Child Q(42);
@@ -62,8 +84,13 @@ int main(void)
 
   /* Set breakpoint marker1 here.  */
 
+  f1(Q);
+  f1(QR);
+  f1(Child(42));
+
   f2(Q);
   f2(QR);
+  f2(Child(42));
 
   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 4531602..8b8a7cf 100644
--- a/gdb/testsuite/gdb.cp/ref-params.exp
+++ b/gdb/testsuite/gdb.cp/ref-params.exp
@@ -24,7 +24,7 @@ if { [skip_cplus_tests] } { continue }
 
 standard_testfile .cc
 
-if {[build_executable $testfile.exp $testfile $srcfile {debug c++}] == 1} {
+if {[build_executable $testfile.exp $testfile $srcfile {debug c++ additional_flags="-std=c++11"}] == 1} {
     return -1
 }
 
@@ -48,15 +48,28 @@ gdb_start_again "marker1 here"
 gdb_test "print f1(QR)" ".* = 42.*" "print value of f1 on (Child&) in main"
 
 gdb_start_again "marker1 here"
+gdb_test "print f1(static_cast<Child&&>(Q))" ".* = 42.*" "print value of f1 on (Child&&) in main"
+
+gdb_start_again "marker1 here"
 gdb_test "print f2(QR)" ".* = 42.*" "print value of f2 on (Child&) in main"
 
+gdb_start_again "marker1 here"
+gdb_test "print f2(static_cast<Child&&>(Q))" ".* = 42.*" "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"
 gdb_test "print f1(C)" ".* = 42.*" "print value of f1 on Child& in f2"
 
 gdb_start_again "marker3 here"
+gdb_test "print C" ".*id = 42.*" "print value of Child&& in f2"
+gdb_test "print f1(C)" ".* = 42.*" "print value of f1 on Child&& in f2"
+
+gdb_start_again "marker4 here"
 gdb_test "print R" ".*id = 42.*" "print value of Parent& in f1"
 
+gdb_start_again "marker5 here"
+gdb_test "print R" ".*id = 42.*" "print value of Parent&& in f1"
+
 gdb_start_again "breakpoint MQ here"
 gdb_test "print f1(MQ)" ".* = 53"
 gdb_test "print mf1(MQ)" ".* = 106"
@@ -64,3 +77,8 @@ 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 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/ref-types.cc b/gdb/testsuite/gdb.cp/ref-types.cc
index 2c124a9..dafec19 100644
--- a/gdb/testsuite/gdb.cp/ref-types.cc
+++ b/gdb/testsuite/gdb.cp/ref-types.cc
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include <utility>
+
 int main2(void);
 
 void marker1 (void)
@@ -39,6 +41,18 @@ int main(void)
     as[2] = 2;
     as[3] = 3;
 
+    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();
@@ -66,15 +80,25 @@ int main2(void)
     float F;
     double D;
     char &rC = C;
+    char &&rrC = 'A';
     unsigned char &rUC = UC;
+    unsigned char &&rrUC = 21;
     short &rS = S;
+    short &&rrS = -14;
     unsigned short &rUS = US;
+    unsigned short &&rrUS = 7;
     int &rI = I;
+    int &&rrI = 102;
     unsigned int &rUI = UI;
+    unsigned int &&rrUI = 1002;
     long &rL = L;
+    long &&rrL = -234;
     unsigned long &rUL = UL;
+    unsigned long &&rrUL = 234;
     float &rF = F;
+    float &&rrF = 1.25E10;
     double &rD = D;
+    double &&rrD = -1.375E-123;
     C = 'A';
     UC = 21;
     S = -14;
diff --git a/gdb/testsuite/gdb.cp/ref-types.exp b/gdb/testsuite/gdb.cp/ref-types.exp
index 3b557f9..5c7c0e5 100644
--- a/gdb/testsuite/gdb.cp/ref-types.exp
+++ b/gdb/testsuite/gdb.cp/ref-types.exp
@@ -24,7 +24,7 @@ if { [skip_cplus_tests] } { continue }
 
 standard_testfile .cc
 
-if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++ additional_flags="-std=c++11"}]} {
     return -1
 }
 
@@ -127,6 +127,47 @@ gdb_test "print ras\[1\]" ".\[0-9\]* = 1" "print value of ras\[1\]"
 gdb_test "print ras\[2\]" ".\[0-9\]* = 2" "print value of ras\[2\]"
 gdb_test "print ras\[3\]" ".\[0-9\]* = 3" "print value of ras\[3\]"
 
+# rvalue reference tests
+
+gdb_test_multiple "print rrt" "print value of rrt" {
+    -re ".\[0-9\]* = \\(short &&\\) @$hex: -1.*$gdb_prompt $" {
+        pass "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_multiple "ptype rrt" "ptype rrt" {
+    -re "type = short &&.*$gdb_prompt $"  { pass "ptype rrt" }
+    -re "type = short int &&.*$gdb_prompt $"  { pass "ptype rrt" }
+}
+
+gdb_test "print *rrpt" ".\[0-9\]* = -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_multiple "ptype rrpt" "ptype rrpt" {
+    -re "type = short \\*&&.*$gdb_prompt $"  { pass "ptype rrpt" }
+    -re "type = short int \\*&&.*$gdb_prompt $"  { pass "ptype rrpt" }
+}
+
+gdb_test "print rrat\[0\]" ".\[0-9\]* = 0" "print value of rrat\[0\]"
+
+gdb_test_multiple "ptype rrat" "ptype rrat" {
+    -re "type = short \\\(&&\\\)\\\[4\\\].*$gdb_prompt $"  { pass "ptype rrat" }
+    -re "type = short int \\\(&&\\\)\\\[4\\\].*$gdb_prompt $"  { pass "ptype rrat" }
+}
+
+gdb_test "print rrat\[1\]" ".\[0-9\]* = 1" "print value of rrat\[1\]"
+gdb_test "print rrat\[2\]" ".\[0-9\]* = 2" "print value of rrat\[2\]"
+gdb_test "print rrat\[3\]" ".\[0-9\]* = 3" "print value of rrat\[3\]"
+
 
 if ![runto 'f'] then {
     perror "couldn't run to f"
@@ -270,3 +311,96 @@ gdb_test "print rD" \
     ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*" \
     "print value of rD"
 
+#
+# test rvalue reference types
+#
+
+gdb_test "ptype rrC" "type = char &&"
+
+gdb_test "ptype rrUC" "type = unsigned char &&"
+
+gdb_test_multiple "ptype rrS" "ptype rrS" {
+    -re "type = short &&.*$gdb_prompt $"  { pass "ptype rrS" }
+    -re "type = short int &&.*$gdb_prompt $"  { pass "ptype rrS" }
+}
+
+gdb_test_multiple "ptype rrUS" "ptype rrUS" {
+    -re "type = unsigned short &&.*$gdb_prompt $"  { pass "ptype rrUS" }
+    -re "type = short unsigned int &&.*$gdb_prompt $"  { pass "ptype rrUS" }
+}
+
+gdb_test "ptype rrI" "type = int &&"
+
+gdb_test "ptype rrUI" "type = unsigned int &&"
+
+gdb_test_multiple "ptype rrL" "ptype rrL" {
+    -re "type = long &&.*$gdb_prompt $"  { pass "ptype rrL" }
+    -re "type = long int &&.*$gdb_prompt $"  { pass "ptype rrL" }
+}
+
+gdb_test_multiple "ptype rrUL" "ptype rrUL" {
+    -re "type = unsigned long &&.*$gdb_prompt $"  { pass "ptype rrUL" }
+    -re "type = long unsigned int &&.*$gdb_prompt $"  { pass "ptype rrUL" }
+}
+
+gdb_test "ptype rrF" "type = float &&"
+
+gdb_test "ptype rrD" "type = double &&"
+
+gdb_test "print rrC" ".\[0-9\]* = \\(char &&\\) @$hex: 65 \'A\'" \
+    "print value of rrC"
+
+gdb_test "print rrUC" \
+    ".\[0-9\]* = \\(unsigned char &&\\) @$hex: 21 \'.025\'" \
+    "print value of rrUC"
+
+gdb_test_multiple "print rrS" "print value of rrS" {
+    -re ".\[0-9\]* = \\(short &&\\) @$hex: -14.*$gdb_prompt $" {
+        pass "print value of rrS"
+    }
+    -re ".\[0-9\]* = \\(short int &&\\) @$hex: -14.*$gdb_prompt $" {
+        pass "print value of rrS"
+    }
+}
+
+gdb_test_multiple "print rrUS" "print value of rrUS" {
+    -re ".\[0-9\]* = \\(unsigned short &&\\) @$hex: 7.*$gdb_prompt $" {
+        pass "print value of rrUS"
+    }
+    -re ".\[0-9\]* = \\(short unsigned int &&\\) @$hex: 7.*$gdb_prompt $" {
+        pass "print value of rrUS"
+    }
+}
+
+gdb_test "print rrI" ".\[0-9\]* = \\(int &&\\) @$hex: 102" \
+	"print value of rrI"
+
+gdb_test "print rrUI" \
+    ".\[0-9\]* = \\(unsigned int &&\\) @$hex: 1002" \
+        "print value of UI"
+
+gdb_test_multiple "print rrL" "print value of rrL" {
+    -re ".\[0-9\]* = \\(long &&\\) @$hex: -234.*$gdb_prompt $" {
+        pass "print value of rrL"
+    }
+    -re ".\[0-9\]* = \\(long int &&\\) @$hex: -234.*$gdb_prompt $" {
+        pass "print value of rrL"
+    }
+}
+
+gdb_test_multiple "print rrUL" "print value of rrUL" {
+    -re ".\[0-9\]* = \\(unsigned long &&\\) @$hex: 234.*$gdb_prompt $" {
+        pass "print value of rrUL"
+    }
+    -re ".\[0-9\]* = \\(long unsigned int &&\\) @$hex: 234.*$gdb_prompt $" {
+        pass "print value of rrUL"
+    }
+}
+
+gdb_test "print rrF" \
+    ".\[0-9\]* = \\(float &&\\) @$hex: 1.2\[0-9\]*e\\+0?10.*" \
+    "print value of rrF"
+
+gdb_test "print rrD" \
+    ".\[0-9\]* = \\(double &&\\) @$hex: -1.375e-123.*" \
+    "print value of rrD"
-- 
2.7.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]