From patchwork Mon Mar 21 20:59:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artemiy Volkov X-Patchwork-Id: 11464 Received: (qmail 80110 invoked by alias); 21 Mar 2016 21:03:00 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 79975 invoked by uid 89); 21 Mar 2016 21:02:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=practically, UD:id, 1002, 643 X-HELO: mail-lb0-f195.google.com Received: from mail-lb0-f195.google.com (HELO mail-lb0-f195.google.com) (209.85.217.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 21 Mar 2016 21:02:27 +0000 Received: by mail-lb0-f195.google.com with SMTP id wn5so11989429lbb.2 for ; Mon, 21 Mar 2016 14:02:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=+H3dywo2DJARumZqRSjBVGLiZXn+zW/tt3eLFOb4l5I=; b=iGF7XN45O/i5qoJkWajYvh+in0uNtJX+MsvchVuWKkYH0dI/cxNWdGUWnyTqBBqA6P Ulbitp/402VfUZzaCaOM3jCthN3U4E5A4K4a28mV5V9282DTKN8ejxKk3/dlVXTtXyEd R42fVNXbS+NZ7TT2FVjtuPvk0hsKe2YFJWvOrSl7FbwA6tzoRKxBqhAeHu3AvLRVBbyC zsbiUu9p6PIf9/JpZdiiNwTzOPU1IZ9Ghz9gEdGvExQXb/5h44ggCphOpN9diPtHmZ8J iZ3TtAIq6UrFQGpGeJ9pWJqyBV6LUKvaG1/VtNijOjqNu/XQVro6nQbKFglu126HaXUl eymQ== X-Gm-Message-State: AD7BkJJY3aKefV9IoZf1T1WLhPzUj8VEbmlITzzdMiS6iyPRnVT1PuWeqVyz+Gfy8OYINg== X-Received: by 10.25.170.145 with SMTP id t139mr12555751lfe.161.1458594142515; Mon, 21 Mar 2016 14:02:22 -0700 (PDT) Received: from arch.smware.local (broadband-90-154-70-182.nationalcablenetworks.ru. [90.154.70.182]) by smtp.gmail.com with ESMTPSA id 40sm4730939lfp.41.2016.03.21.14.02.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Mar 2016 14:02:21 -0700 (PDT) From: Artemiy Volkov To: gdb-patches@sourceware.org Cc: keiths@redhat.com, palves@redhat.com, Artemiy Volkov Subject: [PATCH v4 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Date: Mon, 21 Mar 2016 13:59:18 -0700 Message-Id: <1458593958-25656-12-git-send-email-artemiyv@acm.org> In-Reply-To: <1458593958-25656-1-git-send-email-artemiyv@acm.org> References: <1457147955-21871-1-git-send-email-artemiyv@acm.org> <1458593958-25656-1-git-send-email-artemiyv@acm.org> X-IsSubscribed: yes 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, casts to rvalue reference types, and application of the sizeof operator to rvalue reference types and values, support for rvalue references within the gdb python module. 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. gdb/testsuite/ChangeLog: 2016-03-21 Artemiy Volkov * gdb.cp/casts.cc (main): Add rvalue reference type variables. Include the stdlib header "utility". (decltype) Rename C++11 reserved keyword ... (decl_type) ... to this. All callers updated. * gdb.cp/casts.exp: Compile with -std=c++11. Add rvalue reference cast tests. * gdb.cp/cpsizeof.cc: Add rvalue reference type variables. Include the stdlib header "utility". * gdb.cp/cpsizeof.exp: Compile with -std=c++11. Add rvalue reference sizeof tests. * gdb.cp/demangle.exp (test_gnu_style_demangling): Add rvalue reference demangle tests. * gdb.cp/overload.cc (main): Add typedefs for lvalue and rvalue reference types. 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 (f1, f2, mf1, mf2): New function taking rvalue reference parameter. * gdb.cp/ref-params.exp: Compile with -std=c++11. Add rvalue reference parameter printing tests. * gdb.cp/ref-types.cc (main2): Add rvalue reference type tests. Include the stdlib header "utility". * gdb.cp/ref-types.exp: Compile with -std=c++11. Add rvalue reference type printing tests. * gdb.python/py-value.cc: (func) Add rvalue reference variables. Include the stdlib header "utility". * gdb.python/py-value.exp: Compile with -std=c++11. Add rvalue reference tests. --- gdb/testsuite/gdb.cp/casts.cc | 8 ++- gdb/testsuite/gdb.cp/casts.exp | 35 ++++++++++-- gdb/testsuite/gdb.cp/cpsizeof.cc | 4 ++ gdb/testsuite/gdb.cp/cpsizeof.exp | 3 +- gdb/testsuite/gdb.cp/demangle.exp | 36 +++++++++++++ gdb/testsuite/gdb.cp/overload.cc | 18 ++++++- gdb/testsuite/gdb.cp/overload.exp | 16 +++++- gdb/testsuite/gdb.cp/ref-params.cc | 27 ++++++++++ gdb/testsuite/gdb.cp/ref-params.exp | 21 +++++++- gdb/testsuite/gdb.cp/ref-types.cc | 24 +++++++++ gdb/testsuite/gdb.cp/ref-types.exp | 92 +++++++++++++++++++++++++++++++- gdb/testsuite/gdb.python/py-value-cc.cc | 4 ++ gdb/testsuite/gdb.python/py-value-cc.exp | 10 +++- 13 files changed, 284 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 + 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..2000b77 100644 --- a/gdb/testsuite/gdb.cp/casts.exp +++ b/gdb/testsuite/gdb.cp/casts.exp @@ -33,7 +33,8 @@ 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 +87,18 @@ gdb_test "print (B &) ar" ".* = .B.* { = {a = 42}, b = 1729}" \ gdb_test "print br" ".* = .B.* { = {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 = 42}, b = 1729}" \ + "cast base class rvalue reference to derived class rvalue reference" + +# Check compiler casting +gdb_test "print br" ".* = .B.* { = {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 +114,9 @@ gdb_test "print static_cast (b)" " = \\(A \\*\\) $hex" \ gdb_test "print static_cast (*b)" " = \\(A \\&\\) @$hex: {a = 42}" \ "static_cast to reference type" +gdb_test "print static_cast (*b)" " = \\(A \\&\\&\\) @$hex: {a = 42}" \ + "static_cast to rvalue reference type" + gdb_test "print reinterpret_cast (b)" " = \\(A \\*\\) $hex" \ "basic test of reinterpret_cast" @@ -110,13 +126,16 @@ gdb_test "print reinterpret_cast (b)" "Invalid reinterpret_cast" \ gdb_test "print reinterpret_cast (*b)" " = \\(A \\&\\) @$hex: {a = 42}" \ "reinterpret_cast to reference type" +gdb_test "print reinterpret_cast (*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 +146,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 +172,10 @@ gdb_test "print dynamic_cast (derived)" \ " = \\(Alpha \\&\\) @$nonzero_hex: {.* = ${nonzero_hex}( )?}" \ "dynamic_cast simple upcast to reference" +gdb_test "print dynamic_cast (derived)" \ + " = \\(Alpha \\&\\&\\) @$nonzero_hex: {.* = ${nonzero_hex}( )?}" \ + "dynamic_cast simple upcast to rvalue reference" + gdb_test "print dynamic_cast (ad)" \ " = \\(Derived \\*\\) ${nonzero_hex}( )?" \ "dynamic_cast simple downcast" @@ -169,6 +192,10 @@ gdb_test "print dynamic_cast (*ad)" \ "dynamic_cast failed" \ "dynamic_cast to reference to non-existing base" +gdb_test "print dynamic_cast (*ad)" \ + "dynamic_cast failed" \ + "dynamic_cast to rvalue reference to non-existing base" + gdb_test "print dynamic_cast (add)" \ " = \\(DoublyDerived \\*\\) ${nonzero_hex}( )?" \ "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 . */ +#include + 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..47c841e 100644 --- a/gdb/testsuite/gdb.cp/cpsizeof.exp +++ b/gdb/testsuite/gdb.cp/cpsizeof.exp @@ -18,7 +18,8 @@ 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..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::Pix::Pix(List::Pix const &)" + test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityE3PixC4EOKS2_" \ + "List::Pix::Pix(List::Pix const&&)" test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity7elementRC10VHDLEntityPT0" \ "List::element::element(VHDLEntity const &, List::element *)" + test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityE7elementC2EOKS0_PS2_" \ + "List::element::element(VHDLEntity const&&, List::element*)" test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity7elementRCQ2t4List1Z10VHDLEntity7element" \ "List::element::element(List::element const &)" + test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityE7elementC4EOKS2_" \ + "List::element::element(List::element const&&)" test_demangling_exact "gnu: __cl__C11VHDLLibraryGt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ "VHDLLibrary::operator()(PixX >) const" test_demangling_exact "gnu: __cl__Ct4List1Z10VHDLEntityRCQ2t4List1Z10VHDLEntity3Pix" \ "List::operator()(List::Pix const &) const" + test_demangling_exact "gnu-v3: _ZNK4ListI10VHDLEntityEclEOKNS1_3PixE" \ + "List::operator()(List::Pix const&&) const" test_demangling_exact "gnu: __ne__FPvRCQ2t4List1Z10VHDLEntity3Pix" \ "operator!=(void *, List::Pix const &)" @@ -457,6 +485,8 @@ proc test_gnu_style_demangling {} { test_demangling_exact "gnu: __t4List1Z10VHDLEntityRCt4List1Z10VHDLEntity" \ "List::List(List const &)" + test_demangling_exact "gnu-v3: _ZN4ListI10VHDLEntityEC4EOKS1_" \ + "List::List(List const&&)" test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ "PixX >::PixX(void)" @@ -466,12 +496,18 @@ proc test_gnu_style_demangling {} { test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ "PixX >::PixX(PixX > const &)" + test_demangling_exact "gnu-v3: _ZN4PixXI11VHDLLibrary14VHDLLibraryRep4ListI10VHDLEntityEEC2EOKS5_" \ + "PixX >::PixX(PixX > const&&)" test_demangling_exact "gnu: nextE__C11VHDLLibraryRt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ "VHDLLibrary::nextE(PixX > &) const" + test_demangling_exact "gnu-v3: _ZNK11VHDLLibrary5nextEEO4PixXIS_14VHDLLibraryRep4ListI10VHDLEntityEE" \ + "VHDLLibrary::nextE(PixX >&&) const" test_demangling_exact "gnu: next__Ct4List1Z10VHDLEntityRQ2t4List1Z10VHDLEntity3Pix" \ "List::next(List::Pix &) const" + test_demangling_exact "gnu-v3: _ZNK4ListI10VHDLEntityE4nextEONS1_3PixE" \ + "List::next(List::Pix&&) const" test_demangling_exact "gnu: _GLOBAL_\$D\$set" "global destructors keyed to set" diff --git a/gdb/testsuite/gdb.cp/overload.cc b/gdb/testsuite/gdb.cp/overload.cc index 5c782a4..f9519ff 100644 --- a/gdb/testsuite/gdb.cp/overload.cc +++ b/gdb/testsuite/gdb.cp/overload.cc @@ -1,10 +1,17 @@ #include +#include + +class foo; + +typedef foo &foo_lval_ref; +typedef foo &&foo_rval_ref; class foo { public: foo (int); foo (int, const char *); - foo (foo&); + foo (foo_lval_ref); + foo (foo_rval_ref); ~foo (); void foofunc (int); void foofunc (int, signed char *); @@ -27,6 +34,9 @@ int overload1arg (double); int overload1arg (int*); int overload1arg (void*); +int overload1arg (foo_lval_ref); +int overload1arg (foo_rval_ref); + int overloadfnarg (void); int overloadfnarg (int); int overloadfnarg (int, int (*) (int)); @@ -114,6 +124,7 @@ int main () double arg12 = 200.0; int arg13 = 200; char arg14 = 'a'; + foo arg15(5); A a; B b; @@ -152,7 +163,8 @@ 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_lval_ref afoo) { ifoo = afoo.ifoo; ccpfoo = afoo.ccpfoo;} +foo::foo (foo_rval_ref afoo) { ifoo = std::move(afoo.ifoo); ccpfoo = std::move (afoo.ccpfoo); } foo::~foo () {} @@ -172,6 +184,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_lval_ref arg) { return 15; } +int foo::overload1arg (foo_rval_ref 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..aefac18 100644 --- a/gdb/testsuite/gdb.cp/overload.exp +++ b/gdb/testsuite/gdb.cp/overload.exp @@ -28,7 +28,8 @@ 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 +54,8 @@ 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_lval_ref\\);" +append re_ctor "${ws}foo\\(foo_rval_ref\\);" set re_dtor "~foo\\((void|)\\);" set XX_dtor "~foo\\(int\\);" set re_methods "void foofunc\\(int\\);" @@ -72,6 +74,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 \\*\\);" +append re_methods "${ws}int overload1arg\\(foo_lval_ref\\);" +append re_methods "${ws}int overload1arg\\(foo_rval_ref\\);" 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 +258,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(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..eb46a99 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 + struct Parent { Parent (int id0) : id(id0) { } int id; @@ -31,11 +33,21 @@ int f1(Parent& R) return R.id; /* Set breakpoint marker3 here. */ } +int f1(Parent&& R) +{ + return R.id; /* Set breakpoint marker5 here. */ +} + int f2(Child& C) { return f1(C); /* Set breakpoint marker2 here. */ } +int f2(Child&& C) +{ + return f1(std::move(C)); /* Set breakpoint marker4 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..ce943b8 100644 --- a/gdb/testsuite/gdb.cp/ref-params.exp +++ b/gdb/testsuite/gdb.cp/ref-params.exp @@ -24,7 +24,8 @@ 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 +49,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(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(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 "marker4 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 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 +78,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(MQ))" ".* = 53" +gdb_start_again "breakpoint MQ here" +gdb_test "print mf1(static_cast(MQ))" ".* = 106" +gdb_start_again "breakpoint MQ here" +gdb_test "print mf2(static_cast(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 . */ +#include + 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..682646a 100644 --- a/gdb/testsuite/gdb.cp/ref-types.exp +++ b/gdb/testsuite/gdb.cp/ref-types.exp @@ -24,7 +24,8 @@ 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 +128,35 @@ 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( 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" @@ -270,3 +300,63 @@ 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 "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-value-cc.cc b/gdb/testsuite/gdb.python/py-value-cc.cc index de819d7..188c4fa 100644 --- a/gdb/testsuite/gdb.python/py-value-cc.cc +++ b/gdb/testsuite/gdb.python/py-value-cc.cc @@ -15,6 +15,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include + class A { public: int operator+ (const int a1); @@ -60,8 +62,10 @@ func (const A &a) { int val = 10; int &int_ref = val; + int &&int_rref = std::move(val); int_ptr ptr = &val; int_ptr &int_ptr_ref = ptr; + int_ptr &&int_ptr_rref = std::move(ptr); B b; B b1; diff --git a/gdb/testsuite/gdb.python/py-value-cc.exp b/gdb/testsuite/gdb.python/py-value-cc.exp index d7c5e0b..1e48ab6 100644 --- a/gdb/testsuite/gdb.python/py-value-cc.exp +++ b/gdb/testsuite/gdb.python/py-value-cc.exp @@ -20,7 +20,8 @@ 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 } @@ -39,11 +40,18 @@ gdb_test "python print (str(gdb.parse_and_eval(\"a\").referenced_value().type))" gdb_test "python print (str(gdb.parse_and_eval(\"int_ref\").type))" "int &" gdb_test "python print (str(gdb.parse_and_eval(\"int_ref\").referenced_value().type))" "int" gdb_test "python print (str(gdb.parse_and_eval(\"int_ref\").referenced_value()))" "10" +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_ref\").dereference().type))" "int" gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").referenced_value().type))" "int_ptr" gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").referenced_value().dereference()))" "10" gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").referenced_value().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" # Tests for gdb.Value[gdb.Field] gdb_test_no_output "python b = gdb.parse_and_eval('b')" "init b"