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

fix template union forward declaration, close #1768 #2423

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions bindgen-tests/tests/headers/union_template_forward_decl.hpp
@@ -0,0 +1,17 @@
// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq
//
template <typename value_t>
union declare_union; // Primary template declared, but never defined.

template <typename value_t> union declare_union<value_t *> {
declare_union() {}
declare_union(value_t *a_value) : value(a_value) {}
value_t *value;
};

template <typename value_t> union define_union {
define_union() {}
define_union(value_t *a_value) : value(a_value) {}
value_t *value;
int dummy;
};
3 changes: 3 additions & 0 deletions bindgen/ir/comp.rs
Expand Up @@ -1275,6 +1275,9 @@ impl CompInfo {
CXCursor_ParmDecl => true,
CXCursor_StructDecl | CXCursor_UnionDecl |
CXCursor_ClassDecl => !cur.is_definition(),
CXCursor_ClassTemplate => {
kind == CompKind::Union && !cur.is_definition()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not an issue for structs?

}
_ => false,
});

Expand Down