Skip to content

Commit

Permalink
fix template union forward declaration, close #1768
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielmelody committed Feb 23, 2023
1 parent 2d99bbd commit 82b0d6b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.

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()
}
_ => false,
});

Expand Down

0 comments on commit 82b0d6b

Please sign in to comment.