Skip to content

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

Closed
@emilio

Description

@emilio

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions