summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-04-11 11:56:26 +0200
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-04-11 11:56:26 +0200
commitc68654d2524e42970002273f880fbb7ef1e5bc36 (patch)
tree58bbd9f45bf3d111f9c7407cc816fcf62ac60cd9
parent35b2bca2e4e99672504155cb8eaa395b0c917ea5 (diff)
parser: Handle nested typedefs
-rw-r--r--src/parser.rs8
-rw-r--r--tests/headers/template.hpp13
2 files changed, 18 insertions, 3 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 970e1ec8..50cf4d90 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -633,14 +633,16 @@ fn visit_composite(cursor: &Cursor, parent: &Cursor,
// of the same inner type to cause conflicts
let new_name = [&*ci.name, &*ci2.borrow().name].join("_").to_owned();
ci2.borrow_mut().name = new_name;
+
+ // Propagate template arguments and typedefs to inner structs
+ ci2.borrow_mut().args.extend(ci.args.clone().into_iter());
+ ci2.borrow_mut().typedefs.extend(ci.typedefs.clone().into_iter());
+
cursor.visit(|c, p| {
let mut ci_ = ci2.borrow_mut();
visit_composite(c, p, ctx_, &mut ci_)
});
- // Propagate template types to inner structs
- ci2.borrow_mut().args.extend(ci.args.clone().into_iter());
-
ci.members.push(CompMember::Comp(decl.compinfo()));
// Anonymous structs are legal in both C++ and C11
diff --git a/tests/headers/template.hpp b/tests/headers/template.hpp
index d25d512f..d60f18fb 100644
--- a/tests/headers/template.hpp
+++ b/tests/headers/template.hpp
@@ -5,3 +5,16 @@ template<typename T, typename U> class Foo {
};
void bar(Foo<int, int> foo);
+
+template<typename T>
+class D {
+ typedef Foo<int, int> MyFoo;
+
+ MyFoo m_foo;
+
+ template<typename Z>
+ class U {
+ MyFoo m_nested_foo;
+ Z m_baz;
+ };
+};