Better diagnostics if an attempt is made to redeclare a type under the same name

as an existing type in that scope. Support for anonymous struct/unions.

Change-Id: I0122cfae4da848419956c7b27bacaca66f8021d5
Bug: 30896059
diff --git a/AST.cpp b/AST.cpp
index 20db9b3..d5f8cc7 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -109,6 +109,14 @@
 }
 
 bool AST::addScopedType(const char *localName, NamedType *type) {
+    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);