This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v4] Make chained function calls in expressions work
- From: Siva Chandra <sivachandra at google dot com>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Mon, 3 Nov 2014 13:22:18 -0800
- Subject: Re: [PATCH v4] Make chained function calls in expressions work
- Authentication-results: sourceware.org; auth=none
- References: <CAGyQ6gxhqVQW6eF-ay1UfcW2WgPoa=6=0DJ70dDeWEMJq9By2A at mail dot gmail dot com> <201411031443 dot sA3EhfqM019330 at d06av02 dot portsmouth dot uk dot ibm dot com> <CAGyQ6gzttH0kH5R7bBSTc0prDgE9ogCA-BXjDAaL2nM+S+cc=g at mail dot gmail dot com>
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. 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.