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

Siva Chandra
2014-11-04T15:08:09Z

On Tue, Nov 4, 2014 at 5:43 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> 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) ...

I agree for scalars, but is it worth the effort to make this check for
structs/unions? Consider this example:

struct Simpler
{
char c;
char getc ();
};

struct Simple
{
Simpler a, b;
};

Simple
make_simple ()
{
Simple s;
s.a.c = 'a';
s.b.c = 'b';
return s;
}

Simple does not have any methods, but Simpler has. The ABI returns
objects of Simple type in register. However, one could have an
expression like this: make_simple().a.geta() which is equivalent to
f().g().