Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7246,7 +7246,9 @@ void SemaOpenMP::ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope(
FunctionDecl *UDecl = nullptr;
if (IsTemplated && isa<FunctionTemplateDecl>(CandidateDecl)) {
auto *FTD = cast<FunctionTemplateDecl>(CandidateDecl);
if (FTD->getTemplateParameters()->size() == TemplateParamLists.size())
// FIXME: Should this compare the template parameter lists on all levels?
if (SemaRef.Context.isSameTemplateParameterList(
FTD->getTemplateParameters(), TemplateParamLists.back()))
UDecl = FTD->getTemplatedDecl();
} else if (!IsTemplated)
UDecl = dyn_cast<FunctionDecl>(CandidateDecl);
Expand Down
12 changes: 12 additions & 0 deletions clang/test/SemaOpenMP/openmp-begin-declare-variant_template.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %clang_cc1 -triple x86_64 -fopenmp -verify %s

// FIXME: Is this supposed to work?

#pragma omp begin declare variant match(implementation={extension(allow_templates)})
template <class T> void f(T) {}
// expected-note@-1 {{explicit instantiation refers here}}
#pragma end
template <int> struct A {};
template <bool B> A<B> f() = delete;
template void f<float>(float);
// expected-error@-1 {{explicit instantiation of undefined function template 'f'}}