diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 16dd8f510596..34065a5a212a 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -2576,6 +2576,8 @@ namespace { bool addClassTransitive(CXXRecordDecl *RD) { Classes.insert(RD); + if (InstantiationLoc.isInvalid()) + InstantiationLoc = RD->getLocation(); return ClassesTransitive.insert(RD); } diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 63ea297493ff..dece57bb060a 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -17549,6 +17549,7 @@ static void checkMappableExpressionList( auto &DeclNames = SemaRef.getASTContext().DeclarationNames; MapperId.setName(DeclNames.getIdentifier( &SemaRef.getASTContext().Idents.get("default"))); + MapperId.setLoc(StartLoc); } // Iterators to find the current unresolved mapper expression. diff --git a/clang/test/OpenMP/template-specialization.cpp b/clang/test/OpenMP/template-specialization.cpp new file mode 100644 index 000000000000..714fbf4a2011 --- /dev/null +++ b/clang/test/OpenMP/template-specialization.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -verify -fopenmp -fsyntax-only %s + +// expected-no-diagnostics + +template +struct z { + static void aj() { + T f; +#pragma omp target map(f) + ; + } +}; + +template class ar {}; +template struct as {}; +template class z>>;