diff options
-rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 8 | ||||
-rw-r--r-- | clang/unittests/AST/ASTImporterTest.cpp | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 7e402722b19..3294eda2367 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -4320,9 +4320,13 @@ Decl *ASTNodeImporter::VisitClassTemplateSpecializationDecl( D2->setTemplateSpecializationKind(D->getTemplateSpecializationKind()); - // Add the specialization to this context. + // Set the context of this specialization/instantiation. D2->setLexicalDeclContext(LexicalDC); - LexicalDC->addDeclInternal(D2); + + // Add to the DC only if it was an explicit specialization/instantiation. + if (D2->isExplicitInstantiationOrSpecialization()) { + LexicalDC->addDeclInternal(D2); + } } Importer.Imported(D, D2); if (D->isCompleteDefinition() && ImportDefinition(D, D2)) diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index c95e8fdaf80..76ea2594332 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -1214,7 +1214,7 @@ TEST_P(ASTImporterTestBase, TUshouldNotContainTemplatedDeclOfTypeAlias) { TEST_P( ASTImporterTestBase, - DISABLED_TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) { + TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) { Decl *From, *To; std::tie(From, To) = getImportedDecl( |