summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a0ff449)
structures returned inline from a function call can be copied.
Other structures - in general - cannot.
This patch introduces a (slightly) better way to tell the difference
than the 'space' hack that was previously used.
Signed-off-by: NeilBrown <neil@brown.name>
passed by reference. It has `Efail` set when an error is found, and
`Eretry` when the type for some element is set via propagation. If
any expression cannot be evaluated immediately, `Enoconst` is set.
passed by reference. It has `Efail` set when an error is found, and
`Eretry` when the type for some element is set via propagation. If
any expression cannot be evaluated immediately, `Enoconst` is set.
+If the expression can be copied, `Emaycopy` is set.
If it remains unchanged at `0`, then no more propagation is needed.
###### ast
enum val_rules {Rnolabel = 1<<0, Rboolok = 1<<1, Rnoconstant = 1<<2};
If it remains unchanged at `0`, then no more propagation is needed.
###### ast
enum val_rules {Rnolabel = 1<<0, Rboolok = 1<<1, Rnoconstant = 1<<2};
- enum prop_err {Efail = 1<<0, Eretry = 1<<1, Enoconst = 1<<2};
+ enum prop_err {Efail = 1<<0, Eretry = 1<<1, Enoconst = 1<<2,
+ Emaycopy = 1<<3};
###### format cases
case 'r':
###### format cases
case 'r':
}
*perr |= Enoconst;
v->var->type->check_args(c, perr, v->var->type, args);
}
*perr |= Enoconst;
v->var->type->check_args(c, perr, v->var->type, args);
+ if (v->var->type->function.inline_result)
+ *perr |= Emaycopy;
return v->var->type->function.return_type;
}
return v->var->type->function.return_type;
}
propagate_types(b->left, c, perr, t,
(b->op == Assign ? Rnoconstant : 0));
}
propagate_types(b->left, c, perr, t,
(b->op == Assign ? Rnoconstant : 0));
}
- if (t && t->dup == NULL && t->name.txt[0] != ' ') // HACK
+ if (t && t->dup == NULL && !(*perr & Emaycopy))
type_err(c, "error: cannot assign value of type %1", b, t, 0, NULL);
return Tnone;
type_err(c, "error: cannot assign value of type %1", b, t, 0, NULL);
return Tnone;
* is a list for 'struct var'
*/
struct type *t = add_anon_type(c, &structure_prototype,
* is a list for 'struct var'
*/
struct type *t = add_anon_type(c, &structure_prototype,
int cnt = 0;
struct binode *b;
int cnt = 0;
struct binode *b;