cppparser: fix issue with typedefs to forward declared templates

I don't know if this is the right solution, but it does fix an issue accessing std::ios::openmode caused by the ios typedef being defined before ios_base is fully specified.
This commit is contained in:
rdb 2018-06-04 17:30:02 +02:00
parent 8a9d83b604
commit 5582e174b6
4 changed files with 22 additions and 9 deletions

View File

@ -252,7 +252,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope,
}
while (i + 1 < (int)_names.size() && scope != nullptr) {
CPPScope *next_scope = scope->find_scope(_names[i].get_name());
CPPScope *next_scope = scope->find_scope(_names[i].get_name(), global_scope);
if (next_scope == nullptr) {
if (error_sink != nullptr) {
error_sink->error("Symbol " + _names[i].get_name() +
@ -511,7 +511,7 @@ find_scope(CPPScope *current_scope, CPPScope *global_scope,
if (scope == nullptr) {
return nullptr;
}
return scope->find_scope(get_simple_name());
return scope->find_scope(get_simple_name(), global_scope);
}

View File

@ -605,7 +605,7 @@ find_type(const string &name, CPPDeclaration::SubstDecl &subst,
*
*/
CPPScope *CPPScope::
find_scope(const string &name, bool recurse) const {
find_scope(const string &name, CPPScope *global_scope, bool recurse) const {
Namespaces::const_iterator ni = _namespaces.find(name);
if (ni != _namespaces.end()) {
return (*ni).second->get_scope();
@ -617,13 +617,21 @@ find_scope(const string &name, bool recurse) const {
ti = _types.find(name);
if (ti != _types.end()) {
type = (*ti).second;
// Resolve if this is a typedef or const.
// Resolve if this is a typedef or const, or a TBD type.
while (type->get_subtype() == CPPDeclaration::ST_const ||
type->get_subtype() == CPPDeclaration::ST_typedef) {
type->get_subtype() == CPPDeclaration::ST_typedef ||
type->get_subtype() == CPPDeclaration::ST_tbd) {
if (type->as_typedef_type() != nullptr) {
type = type->as_typedef_type()->_type;
} else {
} else if (type->as_const_type() != nullptr) {
type = type->as_const_type()->_wrapped_around;
} else {
CPPType *new_type = type->resolve_type((CPPScope *)this, global_scope);
if (new_type != type) {
type = new_type;
} else {
break;
}
}
}
@ -653,14 +661,14 @@ find_scope(const string &name, bool recurse) const {
Using::const_iterator ui;
for (ui = _using.begin(); ui != _using.end(); ++ui) {
CPPScope *scope = (*ui)->find_scope(name, false);
CPPScope *scope = (*ui)->find_scope(name, global_scope, false);
if (scope != nullptr) {
return scope;
}
}
if (recurse && _parent_scope != nullptr) {
return _parent_scope->find_scope(name);
return _parent_scope->find_scope(name, global_scope);
}
return nullptr;

View File

@ -87,7 +87,8 @@ public:
CPPDeclaration::SubstDecl &subst,
CPPScope *global_scope,
bool recurse = true) const;
CPPScope *find_scope(const string &name, bool recurse = true) const;
CPPScope *find_scope(const string &name, CPPScope *global_scope,
bool recurse = true) const;
CPPScope *find_scope(const string &name,
CPPDeclaration::SubstDecl &subst,
CPPScope *global_scope,

View File

@ -2267,6 +2267,10 @@ get_type(CPPType *type, bool global) {
return 0;
}
if (type->get_subtype() == CPPType::ST_tbd) {
type = type->resolve_type(&parser, &parser);
}
TypeIndex index = 0;
// First, check to see if it's already there.