Skip to content

Commit 8a10eb1

Browse files
committed
gen: Don't generate constants of templated structs
They're tricky.
1 parent d519313 commit 8a10eb1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/gen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ fn cstruct_to_rs(ctx: &mut GenCtx, name: &str, ci: CompInfo) -> Vec<P<ast::Item>
12391239
items.push(mk_impl(ctx, id_ty, unmangledlist));
12401240
}
12411241

1242-
if !ci.vars.is_empty() {
1242+
if !ci.vars.is_empty() && template_args.is_empty() {
12431243
let vars = ci.vars.into_iter().map(|v| {
12441244
let vi = v.varinfo();
12451245
let v = vi.borrow_mut();

tests/headers/template.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,8 @@ class ReplacedWithDestructorDeclaredAfter {
137137
T* buff;
138138
~ReplacedWithDestructorDeclaredAfter() {};
139139
};
140+
141+
template<typename T>
142+
class TemplateWithVar {
143+
static T var = 0;
144+
};

0 commit comments

Comments
 (0)