diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index 242e6c8a9d7d4..ad7da52d635d0 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -6969,6 +6969,7 @@ bool SYCLIntegrationFooter::emit(raw_ostream &OS) { Policy.adjustForCPlusPlusFwdDecl(); Policy.SuppressTypedefs = true; Policy.SuppressUnwrittenScope = true; + Policy.PrintCanonicalTypes = true; llvm::SmallSet Visited; bool EmittedFirstSpecConstant = false; diff --git a/clang/test/CodeGenSYCL/int_footer_with_explicit_specialization.cpp b/clang/test/CodeGenSYCL/int_footer_with_explicit_specialization.cpp new file mode 100644 index 0000000000000..ec066b4bdaec1 --- /dev/null +++ b/clang/test/CodeGenSYCL/int_footer_with_explicit_specialization.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -fsycl-int-footer=%t.footer.h -emit-llvm %s -o - +// RUN: FileCheck -input-file=%t.footer.h %s --check-prefix=CHECK-FOOTER + +// This test checks that integration footer is emitted correctly when a +// device_global has an explicit template specialization in template arguments. + +#include "sycl.hpp" + +namespace sycl { +template struct X {}; +template <> struct X {}; +namespace detail { +struct Y {}; +} // namespace detail +template <> struct X {}; +} // namespace sycl + +using namespace sycl; +template > struct Arg1 { T val; }; + +using namespace sycl::ext::oneapi; +template +device_global dev_global; + +SYCL_EXTERNAL auto foo() { + (void)dev_global>; +} + +// CHECK-FOOTER: __sycl_device_global_registration::__sycl_device_global_registration() noexcept { +// CHECK-FOOTER-NEXT: device_global_map::add((void *)&::dev_global>>, "_Z10dev_globalI4Arg1IiN4sycl1XINS1_6detail1YEEEEE"); +// CHECK-FOOTER-NEXT: } +// CHECK-FOOTER-NEXT: } // namespace (unnamed)