Fix nested structure/union name handling.
Local names must be assigned before processing the body.
Change-Id: I9c3e3d4b7575c612148aea89bbd424e59e3c0604
diff --git a/AST.cpp b/AST.cpp
index 5939e85..66e54c4 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -18,7 +18,7 @@
: mCoordinator(coordinator),
mPath(path),
mScanner(NULL),
- mRootScope(new Scope) {
+ mRootScope(new Scope("" /* localName */)) {
enterScope(mRootScope);
}
@@ -128,10 +128,9 @@
localName, new TypeDef(type), errorMsg, true /* isTypeDef */);
}
-bool AST::addScopedType(
- const char *localName, NamedType *type, std::string *errorMsg) {
+bool AST::addScopedType(NamedType *type, std::string *errorMsg) {
return addScopedTypeInternal(
- localName, type, errorMsg, false /* isTypeDef */);
+ type->localName().c_str(), type, errorMsg, false /* isTypeDef */);
}
bool AST::addScopedTypeInternal(
@@ -146,14 +145,6 @@
}
}
- std::string anonName;
-
- if (localName == nullptr) {
- // Anonymous type declaration.
- anonName = scope()->pickUniqueAnonymousName();
- localName = anonName.c_str();
- }
-
// LOG(INFO) << "adding scoped type '" << localName << "'";
bool success = scope()->addType(localName, type, errorMsg);
@@ -174,7 +165,6 @@
CHECK(type->isNamedType());
NamedType *namedType = static_cast<NamedType *>(type);
- namedType->setLocalName(localName);
namedType->setFullName(fqName);
}