From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: sivachandra@google.com (Siva Chandra)
Cc: gdb-patches@sourceware.org (gdb-patches)
Subject: Re: [PATCH v4] Make chained function calls in expressions work
Date: Tue, 04 Nov 2014 13:43:00 -0000 [thread overview]
Message-ID: <201411041343.sA4DhRje024520@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <CAGyQ6gyqQYG4fFTaC+v-6ahBacXb6Q6hpOsO+9bsR_3D_f9AZA@mail.gmail.com> from "Siva Chandra" at Nov 03, 2014 01:22:18 PM
Siva Chandra wrote:
> On Mon, Nov 3, 2014 at 11:55 AM, Siva Chandra <sivachandra@google.com> wrote:
> >>>+/* Return true is T is a class or a union. False otherwise. */
> >>>+
> >>>+int
> >>>+class_or_union_p (const struct type *t)
> >>>+{
> >>>+ return (TYPE_CODE (t) == TYPE_CODE_STRUCT
> >>>+ || TYPE_CODE (t) == TYPE_CODE_UNION);
> >>>+}
> >>
> >> I understand we need to do this for classes with member functions (so that
> >> f().g() will work) -- do we really need it for classes without member
> >> functions (or plain C structs)?
> >
> > We could have a struct like this in C++:
> >
> > struct Derived : public virtual Base
> > {
> > ...
> > };
> >
> > Do you mean we should have a language check before reserving space on the stack?
>
> Sorry for revisiting but I thought I can be a bit more elaborate on
> this. To complete the example, I am talking about a case like this:
>
> struct Base
> {
> int base;
> };
>
> struct Derived : public virtual Base
> {
> int derived;
> };
>
> Derived does not have any methods, but will be returned in a hidden
> param as it has a virtual base class.
Well, if it already is returned in a hidden parameter, then we already fall
into the if (hidden_first_param_p) case, so we don't need to do the extra
copy back to the stack, right?
> Even for simple structs like this:
>
> struct Simple
> {
> int simple;
> };
>
> the return value could be a reference argument for a subsequent
> inferior function and hence would still need to be have an address.
Well, that's true. For simple structs, we would have to create a
temporary at the point of call when using a reference; we discussed
adding this anyway (it's necessary for scalars as well) ...
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com
next prev parent reply other threads:[~2014-11-04 13:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-25 14:24 Siva Chandra
2014-11-03 14:35 ` Siva Chandra
2014-11-03 14:43 ` Ulrich Weigand
2014-11-03 19:55 ` Siva Chandra
2014-11-03 21:22 ` Siva Chandra
2014-11-04 13:43 ` Ulrich Weigand [this message]
2014-11-04 15:08 ` Siva Chandra
2014-11-04 15:40 ` Ulrich Weigand
2014-11-04 13:38 ` Ulrich Weigand
2014-11-04 14:26 ` Siva Chandra
2014-11-04 14:59 ` Ulrich Weigand
2014-11-04 15:23 ` Siva Chandra
2014-11-04 15:40 ` Ulrich Weigand
2014-11-11 14:55 ` Siva Chandra
2014-11-11 15:00 ` Siva Chandra
2014-11-11 15:21 ` Ulrich Weigand
2014-11-11 17:05 ` Siva Chandra
2014-11-12 16:08 ` Doug Evans
2014-11-12 17:29 ` Doug Evans
2014-11-13 3:00 ` 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=201411041343.sA4DhRje024520@d06av02.portsmouth.uk.ibm.com \
--to=uweigand@de.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=sivachandra@google.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