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


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


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