Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ppci-cc: impossible to select a field from an struct returned by a function #95

Open
tstreiff opened this issue Jun 23, 2020 · 0 comments
Labels

Comments

@tstreiff
Copy link
Contributor

typedef struct { int x, y; } Point;

Point makepoint(int a, int b) {
Point p;
p.x = a;
p.y = b;
return p;
}

void main() {
Point p = makepoint(2, 6);
printf("(%d, %d)\n", p.x, p.y);

All this works as expected.

printf("(%d, ", makepoint(2, 6).x);

This is very like C++ but it should work as well but:

File "/home/tsf/sandbox/ppci/ppci/ir.py", line 978, in init
raise TypeError("Binop type mismatch {} != {}".format(a.ty, ty))
TypeError: Binop type mismatch blob<8:4> != ptr

In codegenerator.py, gen_field_select() generates the code for the struct base address before adding the field offset.
But it does not expect an object instead of a pointer to an object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants