Skip to content

Commit

Permalink
OpenCL: disallow '#pragma OPENCL EXTENSION all : enable', per OpenCL …
Browse files Browse the repository at this point in the history
…1.1 9.1

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141270 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
pcc committed Oct 6, 2011
1 parent 08f35a7 commit 41c8d6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/Parse/ParsePragma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,11 @@ PragmaOpenCLExtensionHandler::HandlePragma(Preprocessor &PP,
}

OpenCLOptions &f = Actions.getOpenCLOptions();
if (ename->isStr("all")) {
#define OPENCLEXT(nm) f.nm = state;
// OpenCL 1.1 9.1: "The all variant sets the behavior for all extensions,
// overriding all previously issued extension directives, but only if the
// behavior is set to disable."
if (state == 0 && ename->isStr("all")) {
#define OPENCLEXT(nm) f.nm = 0;
#include "clang/Basic/OpenCLExtensions.def"
}
#define OPENCLEXT(nm) else if (ename->isStr(#nm)) { f.nm = state; }
Expand Down
3 changes: 3 additions & 0 deletions test/Parser/opencl-pragma.cl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#pragma OPENCL EXTENSION cl_no_such_extension : disable /* expected-warning {{unknown OpenCL extension 'cl_no_such_extension' - ignoring}} */

#pragma OPENCL EXTENSION all : disable
#pragma OPENCL EXTENSION all : enable /* expected-warning {{unknown OpenCL extension 'all' - ignoring}} */

#pragma OPENCL EXTENSION cl_khr_fp64 : on /* expected-warning {{expected 'enable' or 'disable' - ignoring}} */

#pragma OPENCL FP_CONTRACT ON
Expand Down

0 comments on commit 41c8d6f

Please sign in to comment.