From: Artemiy Volkov <artemiyv@acm.org>
To: gdb-patches@sourceware.org
Cc: palves@redhat.com, keiths@redhat.com, Artemiy Volkov <artemiyv@acm.org>
Subject: [PATCH v5 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests
Date: Mon, 06 Jun 2016 19:23:00 -0000 [thread overview]
Message-ID: <20160606192225.12384-12-artemiyv@acm.org> (raw)
In-Reply-To: <20160606192225.12384-1-artemiyv@acm.org>
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/testsuite/ChangeLog:
2016-06-06 Artemiy Volkov <artemiyv@acm.org>
PR gdb/14441
* 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-overload.cc: New file.
* gdb.cp/rvalue-ref-overload.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/testsuite/gdb.cp/demangle.exp | 36 +++++
gdb/testsuite/gdb.cp/rvalue-ref-casts.cc | 56 +++++++
gdb/testsuite/gdb.cp/rvalue-ref-casts.exp | 76 ++++++++++
gdb/testsuite/gdb.cp/rvalue-ref-overload.cc | 39 +++++
gdb/testsuite/gdb.cp/rvalue-ref-overload.exp | 103 +++++++++++++
gdb/testsuite/gdb.cp/rvalue-ref-params.cc | 74 +++++++++
gdb/testsuite/gdb.cp/rvalue-ref-params.exp | 61 ++++++++
gdb/testsuite/gdb.cp/rvalue-ref-sizeof.cc | 73 +++++++++
gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp | 43 ++++++
gdb/testsuite/gdb.cp/rvalue-ref-types.cc | 73 +++++++++
gdb/testsuite/gdb.cp/rvalue-ref-types.exp | 165 +++++++++++++++++++++
gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc | 55 +++++++
.../gdb.python/py-rvalue-ref-value-cc.exp | 56 +++++++
13 files changed, 910 insertions(+)
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
diff --git a/gdb/testsuite/gdb.cp/demangle.exp b/gdb/testsuite/gdb.cp/demangle.exp
index 96c90db..c007097 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)"
@@ -466,12 +496,18 @@ proc test_gnu_style_demangling {} {
test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
"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"
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..9705c5e
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-casts.cc
@@ -0,0 +1,56 @@
+#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..b756cd9
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-casts.exp
@@ -0,0 +1,76 @@
+# Copyright 2016 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] then {
+ perror "couldn't run to breakpoint"
+ continue
+}
+
+# Prevent symbol on address 0x0 being printed.
+gdb_test_no_output "set print symbol off"
+
+gdb_test "break [gdb_get_line_number "rvalue-ref-casts.exp: 1"]" \
+ "Breakpoint.*at.* file .*" \
+ ""
+
+gdb_test "continue" "Breakpoint .* at .*casts.cc.*" ""
+
+# 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}" \
+ "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)" \
+ " = \\(Alpha \\&\\&\\) @$nonzero_hex: {.* = ${nonzero_hex}( <vtable for Derived.*>)?}" \
+ "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..ca1ac1c
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-overload.cc
@@ -0,0 +1,39 @@
+#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 ()
+{}
+
+int main ()
+{
+ foo foo_rr_instance1;
+ foo arg;
+ marker1 (); // marker1-returns-here
+ return 0;
+}
+
+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..fc94fc6
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-overload.exp
@@ -0,0 +1,103 @@
+# Copyright 2016 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.
+
+set ws "\[\r\n\t \]+"
+set nl "\[\r\n\]+"
+
+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 'marker1'] then {
+ perror "couldn't run to marker1"
+ continue
+}
+
+# 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.
+# See virtfunc.exp for a discussion of ptype.
+#
+# This is hairy to begin with. It is even more hairy because of the
+# XX_* alternate patterns to catch the KFAIL and XFAIL cases.
+
+set re_class "((struct|class) foo \{${ws}public:|struct foo \{)"
+set re_fields ""
+set re_ctor "foo\\(void\\);${ws}foo\\(foo_lval_ref\\);${ws}foo\\(foo_rval_ref\\);"
+set re_dtor "~foo\\((void|)\\);"
+set XX_dtor "~foo\\(int\\);"
+set re_methods "${ws}int overload1arg\\(foo_lval_ref\\);"
+append re_methods "${ws}int overload1arg\\(foo_rval_ref\\);"
+set re_synth "foo & operator=\\(foo const ?&\\);"
+
+gdb_test_multiple "ptype foo_rr_instance1" "ptype foo_rr_instance1" {
+ -re "type = $re_class${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+, no "const" on "const char *"
+ # TODO: gdb.base/constvar.exp has XFAILed this kind of problem for a
+ # long time, but an XFAIL really needs an external bug report.
+ # -- chastain 2003-12-31
+ # setup_xfail "*-*-*"
+ # fail "ptype foo_rr_instance1"
+ # TODO: this should be a KFAIL.
+ pass "ptype foo_rr_instance1 (shorter match)"
+ }
+ -re "type = $re_class${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+ if "const char *" ever gets fixed
+ pass "ptype foo_rr_instance1"
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$XX_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gdwarf-2, "~foo(int)"
+ # TODO: kfail this
+ # kfail "gdb/1113" "ptype foo_rr_instance1"
+ pass "ptype foo_rr_instance1 (shorter match)"
+ }
+ -re "type = $re_class{ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gdwarf-2, if the dtor bug gets fixed
+ # gcc HEAD -gdwarf-2 (abi-2)
+ # TODO: just pass this
+ pass "ptype foo_rr_instance1 (shorter match)"
+ }
+ -re "type = $re_class${ws}$re_synth${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gstabs+
+ # TODO: enough with the "shorter match"
+ pass "ptype foo_rr_instance1 (shorter match)"
+ }
+ -re "type = $re_class${ws}$re_ctor${ws}$re_dtor${ws}$re_methods${ws}$re_synth$nl\}$nl$gdb_prompt $" {
+ # gcc HEAD -gstabs+ (abi-2)
+ pass "ptype foo_rr_instance1 (shorter match)"
+ }
+}
+
+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"
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..467b0e6
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-params.cc
@@ -0,0 +1,74 @@
+/* This test script is part of GDB, the GNU debugger.
+
+ Copyright 2016 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/>. */
+
+/* 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(void)
+{
+ Child Q(42);
+ Child& QR = Q;
+
+ /* Set breakpoint marker1 here. */
+
+ f1(Child(42));
+ 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..e1d01c2
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-params.exp
@@ -0,0 +1,61 @@
+# Copyright 2016 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 {[build_executable $testfile.exp $testfile $srcfile \
+ {debug c++ additional_flags="-std=gnu++11"}] == 1} {
+ return -1
+}
+
+gdb_exit
+
+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))" ".* = 42.*" "print value of f1 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(static_cast<Child&&>(C))" ".* = 42.*" "print value of f1 on Child&& in f2"
+
+gdb_start_again "marker3 here"
+gdb_test "print R" ".*id = 42.*" "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..a747d6f
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.cc
@@ -0,0 +1,73 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2014-2016 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/>. */
+
+#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 (void)
+{
+ 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..1f6c911
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp
@@ -0,0 +1,43 @@
+# Copyright 2016 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 ref 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..602644f
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-types.cc
@@ -0,0 +1,73 @@
+/* This test script is part of GDB, the GNU debugger.
+
+ Copyright 1999-2016 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/>. */
+
+#include <utility>
+
+int main2(void);
+
+void marker1 (void)
+{
+
+}
+
+
+
+int main(void)
+{
+ 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(void)
+{
+ 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..33c5ea8
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-types.exp
@@ -0,0 +1,165 @@
+# Copyright 2016 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] then {
+ perror "couldn't run to breakpoint"
+ continue
+}
+
+if ![runto 'marker1'] then {
+ perror "couldn't run to marker1"
+ continue
+}
+
+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] then {
+ perror "couldn't run to breakpoint"
+ continue
+ }
+
+ if ![runto 'marker1'] then {
+ 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..5edad1a
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc
@@ -0,0 +1,55 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012-2016 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/>. */
+
+#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..f039957
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
@@ -0,0 +1,56 @@
+# Copyright (C) 2016 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] {
+ 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"
--
2.8.3
next prev parent reply other threads:[~2016-06-06 19:23 UTC|newest]
Thread overview: 108+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-20 22:35 [PATCH 00/11] [PR gdb/14441] Support C++0x rvalue references in gdb Artemiy Volkov
2015-12-20 22:35 ` [PATCH 07/11] [PR gdb/14441] gdb: dwarf2read: support DW_AT_rvalue_reference type Artemiy Volkov
2015-12-20 22:35 ` [PATCH 03/11] [PR gdb/14441] gdb: valops: add ability to return rvalue reference values from value_ref() Artemiy Volkov
2015-12-20 22:35 ` [PATCH 08/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check Artemiy Volkov
2015-12-20 22:35 ` [PATCH 10/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Artemiy Volkov
2015-12-20 22:35 ` [PATCH 01/11] [PR gdb/14441] gdb: gdbtypes: add definitions for rvalue reference type Artemiy Volkov
2015-12-20 22:35 ` [PATCH 09/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution Artemiy Volkov
2015-12-20 22:35 ` [PATCH 05/11] [PR gdb/14441] gdb: demangle: implement demangling for rvalue reference typenames Artemiy Volkov
2015-12-30 19:17 ` Pedro Alves
2015-12-20 22:35 ` [PATCH 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Artemiy Volkov
2015-12-20 22:35 ` [PATCH 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API Artemiy Volkov
2015-12-20 22:35 ` [PATCH 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Artemiy Volkov
2015-12-20 22:35 ` [PATCH 04/11] [PR gdb/14441] gdb: parse: support rvalue reference type Artemiy Volkov
2015-12-28 21:09 ` [PATCH 00/11] [PR gdb/14441] Support C++0x rvalue references in gdb Artemiy Volkov
2016-01-20 9:42 ` Yao Qi
2016-01-19 18:54 ` [PATCH v2 " Artemiy Volkov
2016-01-19 18:54 ` [PATCH v2 05/11] [PR gdb/14441] gdb: demangle: implement demangling for rvalue reference typenames Artemiy Volkov
2016-02-19 18:54 ` Keith Seitz
2016-01-19 18:54 ` [PATCH v2 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API Artemiy Volkov
2016-02-19 18:50 ` Keith Seitz
2016-01-19 18:54 ` [PATCH v2 04/11] [PR gdb/14441] gdb: parse: support rvalue reference type Artemiy Volkov
2016-02-19 18:53 ` Keith Seitz
2016-01-19 18:54 ` [PATCH v2 03/11] [PR gdb/14441] gdb: valops: add ability to return rvalue reference values from value_ref() Artemiy Volkov
2016-02-19 18:52 ` Keith Seitz
2016-01-19 18:54 ` [PATCH v2 01/11] [PR gdb/14441] gdb: gdbtypes: add definitions for rvalue reference type Artemiy Volkov
2016-02-19 18:49 ` Keith Seitz
2016-02-23 7:04 ` Artemiy Volkov
2016-02-25 1:22 ` Keith Seitz
2016-02-25 1:32 ` Artemiy Volkov
2016-02-25 1:41 ` Keith Seitz
2016-02-25 1:45 ` Artemiy Volkov
2016-01-19 18:54 ` [PATCH v2 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Artemiy Volkov
2016-02-19 18:56 ` Keith Seitz
2016-01-19 18:55 ` [PATCH v2 10/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Artemiy Volkov
2016-02-19 19:48 ` Keith Seitz
2016-01-19 18:55 ` [PATCH v2 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Artemiy Volkov
2016-02-19 20:05 ` Keith Seitz
2016-01-19 18:55 ` [PATCH v2 08/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check Artemiy Volkov
2016-02-19 19:01 ` Keith Seitz
2016-02-26 5:08 ` Artemiy Volkov
2016-01-19 18:55 ` [PATCH v2 09/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution Artemiy Volkov
2016-02-19 19:46 ` Keith Seitz
2016-01-19 18:55 ` [PATCH v2 07/11] [PR gdb/14441] gdb: dwarf2read: support DW_AT_rvalue_reference type Artemiy Volkov
2016-02-19 18:57 ` Keith Seitz
2016-02-19 18:49 ` [PATCH v2 00/11] [PR gdb/14441] Support C++0x rvalue references in gdb Keith Seitz
2016-02-23 6:04 ` Artemiy Volkov
2016-03-05 3:20 ` [PATCH v3 " Artemiy Volkov
2016-03-05 3:20 ` [PATCH v3 09/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check Artemiy Volkov
2016-03-16 22:41 ` Keith Seitz
2016-03-05 3:20 ` [PATCH v3 01/11] [PR gdb/14441] gdb: gdbtypes: add definitions for rvalue reference type Artemiy Volkov
2016-03-16 22:08 ` Keith Seitz
2016-03-05 3:20 ` [PATCH v3 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Artemiy Volkov
2016-03-16 22:26 ` Keith Seitz
2016-03-05 3:20 ` [PATCH v3 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API Artemiy Volkov
2016-03-16 22:19 ` Keith Seitz
2016-03-20 12:10 ` Artemiy Volkov
2016-03-05 3:20 ` [PATCH v3 08/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Artemiy Volkov
2016-03-16 22:32 ` Keith Seitz
2016-03-05 3:20 ` [PATCH v3 05/11] [PR gdb/14441] gdb: demangle: implement demangling for rvalue reference typenames Artemiy Volkov
2016-03-16 22:25 ` Keith Seitz
2016-03-05 3:20 ` [PATCH v3 03/11] [PR gdb/14441] gdb: valops: add ability to return rvalue reference values from value_ref() Artemiy Volkov
2016-03-16 22:22 ` Keith Seitz
2016-03-05 3:20 ` [PATCH v3 10/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution Artemiy Volkov
2016-03-16 22:45 ` Keith Seitz
2016-03-05 3:20 ` [PATCH v3 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Artemiy Volkov
2016-03-16 22:48 ` Keith Seitz
2016-03-05 3:20 ` [PATCH v3 04/11] [PR gdb/14441] gdb: parse: support rvalue reference type Artemiy Volkov
2016-03-16 22:23 ` Keith Seitz
2016-03-05 3:20 ` [PATCH v3 07/11] [PR gdb/14441] gdb: dwarf2read: support DW_AT_rvalue_reference type Artemiy Volkov
2016-03-16 22:28 ` Keith Seitz
2016-03-21 21:02 ` [PATCH v4 00/11] [PR gdb/14441] Support C++0x rvalue references in gdb Artemiy Volkov
2016-03-21 21:02 ` [PATCH v4 01/11] [PR gdb/14441] gdb: gdbtypes: add definitions for rvalue reference type Artemiy Volkov
2016-03-21 21:02 ` [PATCH v4 07/11] [PR gdb/14441] gdb: dwarf2read: support DW_TAG_rvalue_reference type Artemiy Volkov
2016-03-21 21:02 ` [PATCH v4 08/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Artemiy Volkov
2016-03-31 20:35 ` Keith Seitz
2016-04-02 8:28 ` Artemiy Volkov
2016-04-02 8:45 ` Artemiy Volkov
2016-03-21 21:02 ` [PATCH v4 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Artemiy Volkov
2016-03-21 21:02 ` [PATCH v4 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API Artemiy Volkov
2016-03-21 21:02 ` [PATCH v4 03/11] [PR gdb/14441] gdb: valops: add ability to return rvalue reference values from value_ref() Artemiy Volkov
2016-03-21 21:02 ` [PATCH v4 04/11] [PR gdb/14441] gdb: parse: support rvalue reference type Artemiy Volkov
2016-03-21 21:03 ` [PATCH v4 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Artemiy Volkov
2016-03-21 21:03 ` [PATCH v4 05/11] [PR gdb/14441] gdb: demangle: implement demangling for rvalue reference typenames Artemiy Volkov
2016-03-21 21:03 ` [PATCH v4 09/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check Artemiy Volkov
2016-03-31 20:37 ` Keith Seitz
2016-04-02 8:42 ` Artemiy Volkov
2016-03-21 21:15 ` [PATCH v4 10/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution Artemiy Volkov
2016-03-31 20:35 ` [PATCH v4 00/11] [PR gdb/14441] Support C++0x rvalue references in gdb Keith Seitz
2016-04-02 8:48 ` Artemiy Volkov
2016-04-05 18:23 ` Pedro Alves
[not found] ` <20160406083016.GA31849@gmail.com>
2016-04-12 11:49 ` Pedro Alves
2016-04-19 15:51 ` Artemiy Volkov
2016-04-22 11:31 ` Pedro Alves
2016-06-06 19:22 ` [PATCH v5 00/11] [PR gdb/14441] Support C++11 " Artemiy Volkov
2016-06-06 19:23 ` [PATCH v5 10/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution Artemiy Volkov
2016-06-06 19:23 ` [PATCH v5 03/11] [PR gdb/14441] gdb: valops: add ability to return rvalue reference values from value_ref() Artemiy Volkov
2016-06-06 19:23 ` [PATCH v5 09/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check Artemiy Volkov
2016-06-06 19:23 ` [PATCH v5 08/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Artemiy Volkov
2016-06-20 19:07 ` Pedro Alves
2016-06-06 19:23 ` [PATCH v5 05/11] [PR gdb/14441] gdb: demangle: implement demangling for rvalue reference typenames Artemiy Volkov
2016-06-06 19:23 ` [PATCH v5 04/11] [PR gdb/14441] gdb: parse: support rvalue reference type Artemiy Volkov
2016-06-06 19:23 ` [PATCH v5 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Artemiy Volkov
2016-06-06 19:23 ` [PATCH v5 01/11] [PR gdb/14441] gdb: gdbtypes: add definitions for rvalue reference type Artemiy Volkov
2016-06-06 19:23 ` Artemiy Volkov [this message]
2016-06-20 19:04 ` [PATCH v5 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Pedro Alves
2016-06-06 19:23 ` [PATCH v5 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API Artemiy Volkov
2016-06-06 19:23 ` [PATCH v5 07/11] [PR gdb/14441] gdb: dwarf2read: support DW_TAG_rvalue_reference type Artemiy Volkov
2016-06-19 15:08 ` [PATCH v5 00/11] [PR gdb/14441] Support C++11 rvalue references in gdb Artemiy Volkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160606192225.12384-12-artemiyv@acm.org \
--to=artemiyv@acm.org \
--cc=gdb-patches@sourceware.org \
--cc=keiths@redhat.com \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox