This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v4] Make chained function calls in expressions work


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]