File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -6240,6 +6240,9 @@ ExpectedDecl ASTNodeImporter::VisitVarTemplateDecl(VarTemplateDecl *D) {
6240
6240
// FIXME Check for ODR error if the two definitions have
6241
6241
// different initializers?
6242
6242
return Importer.MapImported (D, FoundDef);
6243
+ if (FoundTemplate->getDeclContext ()->isRecord () &&
6244
+ D->getDeclContext ()->isRecord ())
6245
+ return Importer.MapImported (D, FoundTemplate);
6243
6246
6244
6247
FoundByLookup = FoundTemplate;
6245
6248
break ;
Original file line number Diff line number Diff line change @@ -4988,6 +4988,37 @@ TEST_P(ASTImporterOptionSpecificTestBase,
4988
4988
}
4989
4989
}
4990
4990
4991
+ TEST_P (ImportFriendClasses, RecordVarTemplateDecl) {
4992
+ Decl *ToTU = getToTuDecl (
4993
+ R"(
4994
+ template <class T>
4995
+ class A {
4996
+ public:
4997
+ template <class U>
4998
+ static constexpr bool X = true;
4999
+ };
5000
+ )" ,
5001
+ Lang_CXX14);
5002
+
5003
+ auto *ToTUX = FirstDeclMatcher<VarTemplateDecl>().match (
5004
+ ToTU, varTemplateDecl (hasName (" X" )));
5005
+ Decl *FromTU = getTuDecl (
5006
+ R"(
5007
+ template <class T>
5008
+ class A {
5009
+ public:
5010
+ template <class U>
5011
+ static constexpr bool X = true;
5012
+ };
5013
+ )" ,
5014
+ Lang_CXX14, " input1.cc" );
5015
+ auto *FromX = FirstDeclMatcher<VarTemplateDecl>().match (
5016
+ FromTU, varTemplateDecl (hasName (" X" )));
5017
+ auto *ToX = Import (FromX, Lang_CXX11);
5018
+ EXPECT_TRUE (ToX);
5019
+ EXPECT_EQ (ToTUX, ToX);
5020
+ }
5021
+
4991
5022
TEST_P (ASTImporterOptionSpecificTestBase, VarTemplateParameterDeclContext) {
4992
5023
constexpr auto Code =
4993
5024
R"(
You can’t perform that action at this time.
0 commit comments