]> granicus.if.org Git - clang/commitdiff
OpenCL: disallow '#pragma OPENCL EXTENSION all : enable', per OpenCL 1.1 9.1
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 6 Oct 2011 03:00:50 +0000 (03:00 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 6 Oct 2011 03:00:50 +0000 (03:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141270 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParsePragma.cpp
test/Parser/opencl-pragma.cl

index 16a731b09e31c186c624b3bceb8e23b02ce2ddc4..2ccb6ea88d0f9a7d092a3deb604c8ac1f2f1bfcc 100644 (file)
@@ -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; }
index 5b6c55ab0743be2fb68901bb664a4b083472ff09..19460771137b2a24ebee562cb6bd9ad0a2154620 100644 (file)
@@ -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