Index: lib/AST/ASTImporter.cpp =================================================================== --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -1631,7 +1631,7 @@ // We may already have a record of the same name; try to find and match it. RecordDecl *AdoptDecl = nullptr; RecordDecl *PrevDecl = nullptr; - if (!DC->isFunctionOrMethod()) { + if (!DC->isFunctionOrMethod() && SearchName.getAsString() != "") { SmallVector ConflictingDecls; SmallVector FoundDecls; DC->getRedeclContext()->localUncachedLookup(SearchName, FoundDecls); Index: unittests/AST/ASTImporterTest.cpp =================================================================== --- unittests/AST/ASTImporterTest.cpp +++ unittests/AST/ASTImporterTest.cpp @@ -485,6 +485,36 @@ has(atomicType())))))))))); } +TEST(ImportDecl, ImportUnnamedRecordDecl) { + MatchVerifier Verifier; + EXPECT_TRUE( + testImport( + "void declToImport() {" + " struct Root {" + " struct { int a; } A;" + " struct { float b; } B;" + " } root;" + "}", + Lang_C, "", Lang_C, Verifier, + functionDecl( + hasBody( + compoundStmt( + has( + declStmt( + has( + recordDecl( + has( + recordDecl( + has( + fieldDecl( + hasType(asString("int")))))), + has( + recordDecl( + has( + fieldDecl( + hasType(asString("float")))))) + ))))))))); +} } // end namespace ast_matchers } // end namespace clang