From: Daniel Jacobowitz <drow@false.org>
To: Aleksandar Ristovski <aristovski@qnx.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] fix for c++/2416
Date: Tue, 01 Apr 2008 14:51:00 -0000 [thread overview]
Message-ID: <20080401142948.GE12753@caradoc.them.org> (raw)
In-Reply-To: <47C78DD3.4080109@qnx.com>
On Thu, Feb 28, 2008 at 11:45:07PM -0500, Aleksandar Ristovski wrote:
> Allright, then how about this, yet newer and yet more revisited diff? I
> removed changes to eval.c and let it simply call value_cast as it used to.
> Now value_cast knows how to handle references.
We were converging on a fix and then there's a whole different patch
to look at... sorry I couldn't make time until now.
> @@ -257,6 +290,7 @@ value_cast_pointers (struct type *type,
> return arg2;
> }
>
> +
> /* Cast value ARG2 to type TYPE and return as a value.
> More general than a C cast: accepts any two types of the same length,
> and if ARG2 is an lvalue it can be cast into anything at all. */
Please drop the whitespace change.
> @@ -275,6 +309,26 @@ value_cast (struct type *type, struct va
> if (value_type (arg2) == type)
> return arg2;
>
> + code1 = TYPE_CODE (check_typedef (type));
> +
> + /* Check if we are casting struct reference to struct reference. */
> + if (code1 == TYPE_CODE_REF)
> + {
> + /* We dereference type; then we recurse and finally
> + we generate value of the given reference. Nothing wrong with
> + that. */
> + struct type *t1 = check_typedef (type);
> + struct type *dereftype = check_typedef (TYPE_TARGET_TYPE (t1));
> + struct value *val = value_cast (dereftype, arg2);
> + return value_ref (val);
> + }
This allows things like "(int&) int_var", by automatically creating
references. Should we really do that?
--
Daniel Jacobowitz
CodeSourcery
next prev parent reply other threads:[~2008-04-01 14:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-27 18:43 Aleksandar Ristovski
2008-02-27 19:30 ` Michael Snyder
2008-02-27 19:36 ` Aleksandar Ristovski
2008-02-27 19:47 ` Daniel Jacobowitz
2008-02-27 20:00 ` Aleksandar Ristovski
2008-02-27 20:09 ` Daniel Jacobowitz
2008-02-27 21:26 ` Aleksandar Ristovski
2008-02-27 23:50 ` Daniel Jacobowitz
2008-02-28 19:12 ` Aleksandar Ristovski
2008-02-28 19:39 ` Daniel Jacobowitz
2008-02-29 10:10 ` Aleksandar Ristovski
2008-03-04 19:39 ` Aleksandar Ristovski
2008-04-01 14:51 ` Daniel Jacobowitz [this message]
2008-02-29 2:44 ` Michael Snyder
2008-03-31 19:01 Aleksandar Ristovski
2008-04-01 16:26 Aleksandar Ristovski
2008-04-01 17:06 ` Daniel Jacobowitz
2008-04-01 18:10 Aleksandar Ristovski
2008-04-01 18:52 ` Daniel Jacobowitz
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=20080401142948.GE12753@caradoc.them.org \
--to=drow@false.org \
--cc=aristovski@qnx.com \
--cc=gdb-patches@sourceware.org \
/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