This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Check that global samplers are const
ClosedPublic

Authored by svenvh on May 4 2017, 3:48 AM.

Diff Detail

Event Timeline

svenvh created this revision.May 4 2017, 3:48 AM
yaxunl added inline comments.May 4 2017, 8:07 AM
include/clang/Basic/DiagnosticSemaKinds.td
8301

global sampler requires a const or constant address space qualifier

lib/Sema/SemaDecl.cpp
6085

should be else if ?

if the previous error already happens, it is unnecessary to do the next check

svenvh updated this revision to Diff 97932.May 5 2017, 4:41 AM

Improve diagnostic text as suggested.

svenvh marked an inline comment as done.May 5 2017, 4:48 AM
svenvh added inline comments.
lib/Sema/SemaDecl.cpp
6085

Sure, I can do that, I am just not sure what the desirable behaviour is here? They are different errors, so with the current patch it emits both diagnostics (see the first test change). If we just want one diagnostic (the first one in that test case), I can change it to else if; please let me know if you prefer that.

yaxunl added inline comments.May 5 2017, 6:59 AM
lib/Sema/SemaDecl.cpp
6085

On second thoughts, let's keep it as it is.

Can you add tests for

const sampler_t

const constant sampler_t

const global sampler_t

Thanks.

svenvh updated this revision to Diff 97959.May 5 2017, 8:25 AM

Added more tests as suggested.

yaxunl accepted this revision.May 5 2017, 9:30 AM

LGTM. Thanks!

This revision is now accepted and ready to land.May 5 2017, 9:30 AM
This revision was automatically updated to reflect the committed changes.