This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Disallows static kernel functions in C++ for OpenCL
ClosedPublic

Authored by Topotuna on Sep 2 2021, 5:38 AM.

Details

Summary

It is disallowed in OpenCL C to declare static kernel functions and
C++ for OpenCL is expected to inherit such behaviour. Error is now
correctly reported in C++ for OpenCL when declaring a static kernel
function.

Diff Detail

Event Timeline

Topotuna created this revision.Sep 2 2021, 5:38 AM
Topotuna requested review of this revision.Sep 2 2021, 5:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 2 2021, 5:38 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Anastasia added inline comments.Sep 6 2021, 3:02 AM
clang/lib/Sema/SemaDecl.cpp
9973

I wonder though if we should just drop a version check here completely.

I don't think we can allow this in the earlier OpenCL versions. The reason why it doesn't apply to earlier versions is that static/extern wasn't allowed at all so presumably frontend would reject such a case earlier.

I think the extra check is not doing anything useful here, but only adds extra code to read and maintain.

Topotuna added inline comments.Sep 6 2021, 5:04 AM
clang/lib/Sema/SemaDecl.cpp
9973

That is correct. If static or extern is used in OpenCL C 1.0, diagnostic err_opencl_unknown_type_specifier is displayed before control flow reaches this part of code. And so removing the check here doesn't seem to change the compiler behaviour.

Topotuna updated this revision to Diff 370895.Sep 6 2021, 5:06 AM

Condition on OpenCL C / C++ for OpenCL version removed because it was redundant.

Anastasia accepted this revision.Sep 6 2021, 5:49 AM

Cool! Thanks

This revision is now accepted and ready to land.Sep 6 2021, 5:49 AM