A future patch will want to use this for non-pointers, so make it
work - it is more consistent this way anyway.
Also: update to parsers to use $< where possible.
Signed-off-by: NeilBrown <neil@brown.name>
| NEWLINE }
Block -> Open Statementlist Close ${ $0 = $<2; }$
| Open SimpleStatements } ${ $0 = $<2; }$
- | : Statementlist ${ $0 = $2; $2 = NULL; }$
+ | : Statementlist ${ $0 = $<2; }$
SimpleStatements -> SimpleStatements ; SimpleStatement ${
{
$0->left = $<1;
$0->right = $<3;
}$
- | Term ${ $0 = $1; $1 = NULL; }$
+ | Term ${ $0 = $<1; }$
Term -> Term * Factor ${
$0 = calloc(1, sizeof(struct expression));
$0->op = $2.txt;
$0->left = $<1;
$0->right = $<3;
}$
- | Factor ${ $0 = $1; $1 = NULL; }$
+ | Factor ${ $0 = $<1; }$
Factor -> IDENTIFIER ${
$0 = calloc(1, sizeof(struct expression));
$0->op = $1.txt;
fputs("\n", f);
for (i = 0; i < p->body_size; i++) {
if (p->body[i]->struct_name.txt &&
- p->body[i]->isref &&
- used[i])
+ used[i]) {
// assume this has been copied out
- fprintf(f, "\t\t*(void**)body[%d] = NULL;\n", i);
+ if (p->body[i]->isref)
+ fprintf(f, "\t\t*(void**)body[%d] = NULL;\n", i);
+ else
+ fprintf(f, "\t\tmemset(body[%d], 0, sizeof(struct %.*s));\n", i, p->body[i]->struct_name.len, p->body[i]->struct_name.txt);
+ }
}
free(used);
}