]> granicus.if.org Git - clang/commitdiff
[OpenCL] Re-enable supported core extensions based on opencl version when disabling...
authorKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>
Fri, 6 Jan 2017 16:14:41 +0000 (16:14 +0000)
committerKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>
Fri, 6 Jan 2017 16:14:41 +0000 (16:14 +0000)
Differential Revision: https://reviews.llvm.org/D28257

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291243 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParsePragma.cpp
test/SemaOpenCL/extensions.cl

index 2dc6a0739bc84e34292289fbf326d0f2ec30c3e6..89733237c15305047dfbebfdeb0cc7c16871e2a7 100644 (file)
@@ -506,10 +506,12 @@ void Parser::HandlePragmaOpenCLExtension() {
   // overriding all previously issued extension directives, but only if the
   // behavior is set to disable."
   if (Name == "all") {
-    if (State == Disable)
+    if (State == Disable) {
       Opt.disableAll();
-    else
+      Opt.enableSupportedCore(getLangOpts().OpenCLVersion);
+    } else {
       PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1;
+    }
   } else if (State == Begin) {
     if (!Opt.isKnown(Name) ||
         !Opt.isSupported(Name, getLangOpts().OpenCLVersion)) {
index c27f3397cd79ea2f7e3f6ccbca59fcb8b54b3e97..6afb11e42a6a8156a1b98c38118747093bda8475 100644 (file)
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
 
+// Test with -finclude-default-header, which includes opencl-c.h. opencl-c.h
+// disables all extensions by default, but supported core extensions for a
+// particular OpenCL version must be re-enabled (for example, cl_khr_fp64 is
+// enabled by default with -cl-std=CL2.0).
+//
+// RUN: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
+
+#ifdef _OPENCL_H_
+// expected-no-diagnostics
+#endif
+
 #ifdef FP64
 // expected-no-diagnostics
 #endif
@@ -33,6 +44,7 @@ void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 exte
 }
 #endif
 
+#ifndef _OPENCL_H_
 int isnan(float x) {
     return __builtin_isnan(x);
 }
@@ -40,6 +52,7 @@ int isnan(float x) {
 int isfinite(float x) {
     return __builtin_isfinite(x);
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64