From patchwork Thu Sep 11 18:36:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siva Chandra Reddy X-Patchwork-Id: 2770 Received: (qmail 18209 invoked by alias); 11 Sep 2014 18:36:12 -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 18200 invoked by uid 89); 11 Sep 2014 18:36:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f181.google.com Received: from mail-ob0-f181.google.com (HELO mail-ob0-f181.google.com) (209.85.214.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 11 Sep 2014 18:36:10 +0000 Received: by mail-ob0-f181.google.com with SMTP id vb8so14386273obc.26 for ; Thu, 11 Sep 2014 11:36:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=jj4u0YXYa1K3kbaAqVy8xZtMKmIZMyO3/Vqm/G3fXR0=; b=WmRawvBT18hvW0LEuXw9xQsCiayGwnh3ycECCwugXD+XoyTV3b3xTLuO/nrsEx5M1P 717bOMP/K3akHZoWrIDePJ7E8n1lAiTNjI5khNKVbo5HaolH22ZRPMO9X5w6BN/DMu0t Wtzy6dHIkB5DjKuhRLQNt6ce8q1fnhJZ6QGOFu7JxA5UmyoGSEhi9OC6GRRb+7azNTE2 ZJ31rrvTqYVzVXlZU/QwkiJshI6JNH4xH5ALnV4j6oYmb5FD13zokkn6LfUW5BpuwTal Rj6SF7JykAmWPvbFrxHQ9ITppIWri8gQrMokXnY52+KnMQuwKdAUTPCZ18dcZVAH0UrL OPkA== X-Gm-Message-State: ALoCoQlG9LhWfFN2pgbYgTJmT29ypK/Vl5ekdO2rway4BuicWCb8aCO2nclvI4XNBhOUHHWl0CxO MIME-Version: 1.0 X-Received: by 10.60.63.201 with SMTP id i9mr3164940oes.52.1410460568271; Thu, 11 Sep 2014 11:36:08 -0700 (PDT) Received: by 10.202.225.135 with HTTP; Thu, 11 Sep 2014 11:36:08 -0700 (PDT) Date: Thu, 11 Sep 2014 11:36:08 -0700 Message-ID: Subject: [PATCH 1/4] PR c++/13403 and PR c++/15154: Non trivial return value tests From: Siva Chandra To: gdb-patches X-IsSubscribed: yes Adds two tests, one fails and another passes. These tests illustrate the way in which the ABI function gnuv3_pass_by_reference is incomplete. gdb/testsuite/ChangeLog: 2014-09-11 Siva Chandra Reddy PR c++/13403 PR c++/15154 * gdb.cp/non-trivial-retval.cc: New file. * gdb.cp/non-trivial-retval.exp: New file. diff --git a/gdb/testsuite/gdb.cp/non-trivial-retval.cc b/gdb/testsuite/gdb.cp/non-trivial-retval.cc new file mode 100644 index 0000000..c7a2d35 --- /dev/null +++ b/gdb/testsuite/gdb.cp/non-trivial-retval.cc @@ -0,0 +1,73 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2014 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 . */ + +class A +{ +public: + A () {} + A (A &obj); + + int a; +}; + +A::A(A &obj) +{ + a = obj.a; +} + +A +f1 (int i1, int i2) +{ + A a; + + a.a = i1 + i2; + + return a; +} + +class B +{ +public: + B () {} + B (const B &obj); + + int b; +}; + +B::B(const B &obj) +{ + b = obj.b; +} + +B +f2 (int i1, int i2) +{ + B b; + + b.b = i1 + i2; + + return b; +} + +int +main (void) +{ + int i1 = 1; + int i2 = 10; + + return 0; /* Break here */ +} diff --git a/gdb/testsuite/gdb.cp/non-trivial-retval.exp b/gdb/testsuite/gdb.cp/non-trivial-retval.exp new file mode 100644 index 0000000..a629339 --- /dev/null +++ b/gdb/testsuite/gdb.cp/non-trivial-retval.exp @@ -0,0 +1,34 @@ +# Copyright 2014 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 . + +# This file is part of the gdb testsuite + +if {[skip_cplus_tests]} { continue } + +standard_testfile .cc + +if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { + return -1 +} + +if {![runto_main]} { + return -1 +} + +gdb_breakpoint [gdb_get_line_number "Break here"] +gdb_continue_to_breakpoint "Break here" + +gdb_test "p f1 (i1, i2)" ".*a = 11.*" "p f1 (i1, i2)" +gdb_test "p f2 (i1, i2)" ".*b = 11.*" "p f2 (i1, i2)"