Skip to content

[SYCL] Omit TemplatedDecl from int-footer for a VarTemplateDecl #4108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2021
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
5 changes: 4 additions & 1 deletion clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,10 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D,
if (Var->isStaticLocal())
SemaRef.CheckStaticLocalForDllExport(Var);

SemaRef.addSyclVarDecl(Var);
// Only add this if we aren't instantiating a variable template. We'll end up
// adding the VarTemplateSpecializationDecl later.
if (!InstantiatingVarTemplate)
SemaRef.addSyclVarDecl(Var);
return Var;
}

Expand Down
10 changes: 10 additions & 0 deletions clang/test/CodeGenSYCL/integration_footer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,14 @@ auto x = HasVarTemplate::VarTempl<int, 2>.getDefaultValue();
// CHECK-NEXT: } // namespace sycl
// CHECK-NEXT: } // __SYCL_INLINE_NAMESPACE(cl)

template <typename T> struct GlobalWrapper {
template<int Value> static constexpr specialization_id<T> sc{Value};
};

auto &y = GlobalWrapper<int>::template sc<20>;

// Should not generate the uninstantiated template.
// CHECK-NOT: inline const char *get_spec_constant_symbolic_ID_impl<::GlobalWrapper<int>::sc>()
// CHECK: inline const char *get_spec_constant_symbolic_ID_impl<::GlobalWrapper<int>::sc<20>>()

// CHECK: #include <CL/sycl/detail/spec_const_integration.hpp>