Skip to content

Incorrect item parenthood while referencing incomplete types without a previous declaration. #482

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

Closed
emilio opened this issue Feb 5, 2017 · 2 comments
Labels

Comments

@emilio
Copy link
Contributor

emilio commented Feb 5, 2017

Noticed while reviewing #468, the following code:

struct cmdline_token_hdr {
	struct cmdline_token_ops *ops;
};

struct cmdline_token_ops {
  int foo;
};

Makes bindgen believe that cmdline_token_ops is defined inside cmdline_token_hdr. The reason is that clang inserts a RecorDecl cursor before the field declaration, which we parse thinking it is declared as a child.

We should probably treat this as an unresolved type reference, but that has the unexpected side effect of making the inner_items of a struct/class ResolvedTyperefs, for which we don't generate code.

I believe generating code for them would be ok because we track all the types seen so far, but worth re-checking.

Unfortunately using this super-naive approach would regress other stuff like:

class A {
public:
    int member_a;
    class B {
        int member_b;
    };
};

A::B var;

So I'll have to think a bit harder about how to address this. Probably checking and ignoring non-definitions?

@emilio emilio added the bug label Feb 5, 2017
@emilio
Copy link
Contributor Author

emilio commented Feb 5, 2017

That doesn't work because doing so would regress:

class A {
    class B;
};

class A::B {
    int foo;
};

@emilio
Copy link
Contributor Author

emilio commented Feb 5, 2017

Well, of course, I'm stupid, and I could just check whether the semantic parent is the current class, I'll write a patch tomorrow, probably.

emilio added a commit to emilio/rust-bindgen that referenced this issue Feb 7, 2017
emilio added a commit to emilio/rust-bindgen that referenced this issue Feb 8, 2017
emilio added a commit to emilio/rust-bindgen that referenced this issue Feb 8, 2017
emilio added a commit to emilio/rust-bindgen that referenced this issue Feb 8, 2017
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

1 participant