diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index 2d1845e41c9de..a28b2ac7e6162 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -1316,8 +1316,9 @@ void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) { if (Node->hasTemplateKeyword()) OS << "template "; - bool ForceAnonymous = - Policy.PrintAsCanonical && VD->getKind() == Decl::NonTypeTemplateParm; + bool ForceAnonymous = Policy.PrintAsCanonical && + !Policy.SkipCanonicalizationOfTemplateTypeParms && + VD->getKind() == Decl::NonTypeTemplateParm; DeclarationNameInfo NameInfo = Node->getNameInfo(); if (IdentifierInfo *ID = NameInfo.getName().getAsIdentifierInfo(); !ForceAnonymous && diff --git a/clang/test/CodeGenSYCL/int_header_nttp.cpp b/clang/test/CodeGenSYCL/int_header_nttp.cpp index 507e6b207246b..fe0ee3213f98f 100644 --- a/clang/test/CodeGenSYCL/int_header_nttp.cpp +++ b/clang/test/CodeGenSYCL/int_header_nttp.cpp @@ -8,6 +8,7 @@ // CHECK: Forward declarations of templated kernel function types: // CHECK-NEXT: template struct SelfReferentialNTTP; // CHECK-NEXT: template struct NonSelfRef; +// CHECK-NEXT: template struct alignas(N) OpaqueType; template struct SelfReferentialNTTP {}; @@ -17,7 +18,15 @@ using Foo = int; template struct NonSelfRef {}; +template struct alignas(N) OpaqueType { + char data[N]; +}; +template class Kernel; + void foo() { - sycl::kernel_single_task>([](){}); - sycl::kernel_single_task>([](){}); + auto Lambda = [](){}; + sycl::kernel_single_task>(Lambda); + sycl::kernel_single_task>(Lambda); + using scalar_t = OpaqueType; + sycl::kernel_single_task>(Lambda); }