Skip to content

Cast Integer to enumeration type using static_cast for KernelNameType #1895

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 3 commits into from
Jun 17, 2020
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/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,9 @@ static void printArgument(ASTContext &Ctx, raw_ostream &ArgOS,

if (ET) {
const llvm::APSInt &Val = Arg.getAsIntegral();
ArgOS << "(" << ET->getDecl()->getQualifiedNameAsString() << ")" << Val;
ArgOS << "static_cast<" << ET->getDecl()->getQualifiedNameAsString()
<< ">"
<< "(" << Val << ")";
} else {
Arg.print(P, ArgOS);
}
Expand Down
14 changes: 7 additions & 7 deletions clang/test/CodeGenSYCL/kernelname-enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ int main() {
// CHECK: template <EnumValueIn EnumValue, typename EnumTypeIn> class Baz;
// CHECK: template <typename EnumTypeOut, template <EnumValueIn EnumValue, typename EnumTypeIn> class T> class dummy_functor_8;
// CHECK: Specializations of KernelInfo for kernel function types:
// CHECK: template <> struct KernelInfo<::dummy_functor_1<(no_namespace_int)0>>
// CHECK: template <> struct KernelInfo<::dummy_functor_2<(no_namespace_short)1>>
// CHECK: template <> struct KernelInfo<::dummy_functor_3<(internal::namespace_short)1>>
// CHECK: template <> struct KernelInfo<::dummy_functor_4<(enum_in_anonNS)1>>
// CHECK: template <> struct KernelInfo<::dummy_functor_5<(no_type_set)0>>
// CHECK: template <> struct KernelInfo<::dummy_functor_6<(unscoped_enum)0>>
// CHECK: template <> struct KernelInfo<::dummy_functor_1<static_cast<no_namespace_int>(0)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_2<static_cast<no_namespace_short>(1)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_3<static_cast<internal::namespace_short>(1)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_4<static_cast<enum_in_anonNS>(1)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_5<static_cast<no_type_set>(0)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_6<static_cast<unscoped_enum>(0)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_7<::no_namespace_int>>
// CHECK: template <> struct KernelInfo<::dummy_functor_7<::internal::namespace_short>>
// CHECK: template <> struct KernelInfo<::T1<::T2<(type_argument_template_enum::E)0>>>
// CHECK: template <> struct KernelInfo<::T1<::T2<static_cast<type_argument_template_enum::E>(0)>>>
// CHECK: template <> struct KernelInfo<::T1<::T3<::type_argument_template_enum::E>>>
// CHECK: template <> struct KernelInfo<::dummy_functor_8<::EnumTypeOut, Baz>>