Skip to content

Commit 81fba23

Browse files
Danielmelodyjohnrichardrinehart
authored andcommitted
fix template union forward declaration, close rust-lang#1768
1 parent 3300618 commit 81fba23

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

Diff for: bindgen-tests/tests/expectations/tests/union_template_forward_decl.rs

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq
2+
//
3+
template <typename value_t>
4+
union declare_union; // Primary template declared, but never defined.
5+
6+
template <typename value_t> union declare_union<value_t *> {
7+
declare_union() {}
8+
declare_union(value_t *a_value) : value(a_value) {}
9+
value_t *value;
10+
};
11+
12+
template <typename value_t> union define_union {
13+
define_union() {}
14+
define_union(value_t *a_value) : value(a_value) {}
15+
value_t *value;
16+
int dummy;
17+
};

Diff for: bindgen/ir/comp.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1278,14 +1278,15 @@ impl CompInfo {
12781278

12791279
let kind = kind?;
12801280

1281-
debug!("CompInfo::from_ty({:?}, {:?})", kind, cursor);
1281+
println!("CompInfo::from_ty({:?}, {:?})", kind, cursor);
12821282

12831283
let mut ci = CompInfo::new(kind);
12841284
ci.is_forward_declaration =
12851285
location.map_or(true, |cur| match cur.kind() {
12861286
CXCursor_ParmDecl => true,
12871287
CXCursor_StructDecl | CXCursor_UnionDecl |
12881288
CXCursor_ClassDecl => !cur.is_definition(),
1289+
CXCursor_ClassTemplate => kind == CompKind::Union && !cur.is_definition(),
12891290
_ => false,
12901291
});
12911292

0 commit comments

Comments
 (0)