From: Siva Chandra <sivachandra@google.com>
To: Doug Evans <dje@google.com>, gdb-patches <gdb-patches@sourceware.org>
Cc: Sergio Durigan Junior <sergiodj@redhat.com>,
Pedro Alves <palves@redhat.com>
Subject: Re: [PATCH] Guard a call to TYPE_TARGET_TYPE in gnuv3_pass_by_reference
Date: Thu, 16 Oct 2014 19:01:00 -0000 [thread overview]
Message-ID: <CAGyQ6gy9eObF+29DSibKj4xxiw9NpoWtarVJTtd-j_A7LBnktA@mail.gmail.com> (raw)
In-Reply-To: <CAGyQ6gzAMpiA8Hwt1=DqmFxXjfe44nqGsCqsj-fx=ObJbgPAsA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 348 bytes --]
The patch updated with a test case is attached.
gdb/ChangeLog:
* gnu-v3-abi.c (gnuv3_pass_by_reference): Call TYPE_TARGET_TYPE
on the arg type of a constructor only if it is of reference type.
gdb/testsuite/ChangeLog:
* gdb.cp/non-trivial-retval.cc: Add a test case.
* gdb.cp/non-trivial-retval.exp: Add a test.
[-- Attachment #2: gnuv3_pass_by_reference_v2.txt --]
[-- Type: text/plain, Size: 1986 bytes --]
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index a6c6f9f..b960aa3 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -1320,13 +1320,15 @@ gnuv3_pass_by_reference (struct type *type)
if (TYPE_NFIELDS (fieldtype) == 2)
{
struct type *arg_type = TYPE_FIELD_TYPE (fieldtype, 1);
- struct type *arg_target_type;
- arg_target_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
+ if (TYPE_CODE (arg_type) == TYPE_CODE_REF)
+ {
+ struct type *arg_target_type;
- if (TYPE_CODE (arg_type) == TYPE_CODE_REF
- && class_types_same_p (arg_target_type, type))
- return 1;
+ arg_target_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
+ if (class_types_same_p (arg_target_type, type))
+ return 1;
+ }
}
}
diff --git a/gdb/testsuite/gdb.cp/non-trivial-retval.cc b/gdb/testsuite/gdb.cp/non-trivial-retval.cc
index 8382f40..aeb7875 100644
--- a/gdb/testsuite/gdb.cp/non-trivial-retval.cc
+++ b/gdb/testsuite/gdb.cp/non-trivial-retval.cc
@@ -63,6 +63,33 @@ f2 (int i1, int i2)
return b;
}
+class B1
+{
+public:
+ B1 () {}
+ B1 (int i); /* Put this decl before the copy-ctor decl. */
+ B1 (const B1 &obj);
+
+ int b1;
+};
+
+B1::B1 (const B1 &obj)
+{
+ b1 = obj.b1;
+}
+
+B1::B1 (int i) : b1 (i) { }
+
+B1
+f22 (int i1, int i2)
+{
+ B1 b1;
+
+ b1.b1 = i1 + i2;
+
+ return b1;
+}
+
class C
{
public:
diff --git a/gdb/testsuite/gdb.cp/non-trivial-retval.exp b/gdb/testsuite/gdb.cp/non-trivial-retval.exp
index 7934946..3450a94 100644
--- a/gdb/testsuite/gdb.cp/non-trivial-retval.exp
+++ b/gdb/testsuite/gdb.cp/non-trivial-retval.exp
@@ -32,5 +32,6 @@ gdb_continue_to_breakpoint "Break here"
gdb_test "p f1 (i1, i2)" ".* = {a = 123}" "p f1 (i1, i2)"
gdb_test "p f2 (i1, i2)" ".* = {b = 123}" "p f2 (i1, i2)"
+gdb_test "p f22 (i1, i2)" ".* = {b1 = 123}" "p f22 (i1, i2)"
gdb_test "p f3 (i1, i2)" ".* = {.* c = 123}" "p f3 (i1, i2)"
gdb_test "p f4 (i1, i2)" ".* = {.* e = 123}" "p f4 (i1, i2)"
next prev parent reply other threads:[~2014-10-16 19:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-16 14:38 Siva Chandra
2014-10-16 18:01 ` Pedro Alves
2014-10-16 18:10 ` Siva Chandra
2014-10-16 18:16 ` Sergio Durigan Junior
2014-10-16 18:18 ` Siva Chandra
2014-10-16 18:28 ` Sergio Durigan Junior
2014-10-16 19:01 ` Siva Chandra [this message]
2014-10-16 20:42 ` Pedro Alves
2014-10-23 19:09 ` Siva Chandra
2014-10-24 5:31 ` Doug Evans
2014-10-24 12:56 ` Siva Chandra
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=CAGyQ6gy9eObF+29DSibKj4xxiw9NpoWtarVJTtd-j_A7LBnktA@mail.gmail.com \
--to=sivachandra@google.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=sergiodj@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