Skip to content

Commit 30b0359

Browse files
committed
fixup
1 parent 2ff7310 commit 30b0359

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5292,7 +5292,12 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
52925292
});
52935293
assert(It != Primary->redecls().end() &&
52945294
"Should't get here without a definition");
5295-
DC = (*It)->getLexicalDeclContext();
5295+
if (FunctionDecl *Def = cast<FunctionTemplateDecl>(*It)
5296+
->getTemplatedDecl()
5297+
->getDefinition())
5298+
DC = Def->getLexicalDeclContext();
5299+
else
5300+
DC = (*It)->getLexicalDeclContext();
52965301
Innermost.emplace(Function->getTemplateSpecializationArgs()->asArray());
52975302
}
52985303
MultiLevelTemplateArgumentList TemplateArgs = getTemplateInstantiationArgs(

clang/test/SemaTemplate/GH55509.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,14 @@ namespace regression1 {
9999

100100
template void foo<int>(A<int>);
101101
} // namespace regression1
102+
namespace regression2 {
103+
template <class> struct A {
104+
template <class T> static void f() {
105+
A<int>::f<T>();
106+
}
107+
};
108+
template <> template <class T> void A<int>::f() {
109+
static_assert(__is_same(T, long));
110+
}
111+
template void A<void>::f<long>();
112+
} // namespace regression2

0 commit comments

Comments
 (0)