[PATCH] D28257: [OpenCL] Re-enable supported core extensions based on opencl version when disabling all extensions using pragma

2017-01-06 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291243: [OpenCL] Re-enable supported core extensions based 
on opencl version when… (authored by kzhuravl).

Changed prior to commit:
  https://reviews.llvm.org/D28257?vs=82956=83369#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28257

Files:
  cfe/trunk/lib/Parse/ParsePragma.cpp
  cfe/trunk/test/SemaOpenCL/extensions.cl


Index: cfe/trunk/lib/Parse/ParsePragma.cpp
===
--- cfe/trunk/lib/Parse/ParsePragma.cpp
+++ cfe/trunk/lib/Parse/ParsePragma.cpp
@@ -506,10 +506,12 @@
   // 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: cfe/trunk/test/SemaOpenCL/extensions.cl
===
--- cfe/trunk/test/SemaOpenCL/extensions.cl
+++ cfe/trunk/test/SemaOpenCL/extensions.cl
@@ -22,6 +22,17 @@
 // 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,13 +44,15 @@
 }
 #endif
 
+#ifndef _OPENCL_H_
 int isnan(float x) {
 return __builtin_isnan(x);
 }
 
 int isfinite(float x) {
 return __builtin_isfinite(x);
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64


Index: cfe/trunk/lib/Parse/ParsePragma.cpp
===
--- cfe/trunk/lib/Parse/ParsePragma.cpp
+++ cfe/trunk/lib/Parse/ParsePragma.cpp
@@ -506,10 +506,12 @@
   // 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: cfe/trunk/test/SemaOpenCL/extensions.cl
===
--- cfe/trunk/test/SemaOpenCL/extensions.cl
+++ cfe/trunk/test/SemaOpenCL/extensions.cl
@@ -22,6 +22,17 @@
 // 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,13 +44,15 @@
 }
 #endif
 
+#ifndef _OPENCL_H_
 int isnan(float x) {
 return __builtin_isnan(x);
 }
 
 int isfinite(float x) {
 return __builtin_isfinite(x);
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28257: [OpenCL] Re-enable supported core extensions based on opencl version when disabling all extensions using pragma

2017-01-05 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

Ok, LGTM! Thanks!


https://reviews.llvm.org/D28257



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28257: [OpenCL] Re-enable supported core extensions based on opencl version when disabling all extensions using pragma

2017-01-04 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added inline comments.



Comment at: test/SemaOpenCL/extensions.cl:47
 
+#ifndef _OPENCL_H_
 int isnan(float x) {

Anastasia wrote:
> Why do you need this?
`isnan` and `isfinite` are declared in opencl-c.h, so without guards I am 
getting redeclation diagnostics. Alternatively we can add overloadable 
attribute to `isnan` and `isfinite` in the test to avoid those diagnostic 
messages?


https://reviews.llvm.org/D28257



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28257: [OpenCL] Re-enable supported core extensions based on opencl version when disabling all extensions using pragma

2017-01-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/SemaOpenCL/extensions.cl:47
 
+#ifndef _OPENCL_H_
 int isnan(float x) {

Why do you need this?


https://reviews.llvm.org/D28257



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28257: [OpenCL] Re-enable supported core extensions based on opencl version when disabling all extensions using pragma

2017-01-03 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
kzhuravl added reviewers: yaxunl, Anastasia, b-sumner.
kzhuravl added a subscriber: cfe-commits.
Herald added a subscriber: wdng.

https://reviews.llvm.org/D28257

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


Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -22,6 +22,17 @@
 // 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,13 +44,15 @@
 }
 #endif
 
+#ifndef _OPENCL_H_
 int isnan(float x) {
 return __builtin_isnan(x);
 }
 
 int isfinite(float x) {
 return __builtin_isfinite(x);
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64
Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -506,10 +506,12 @@
   // 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: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -22,6 +22,17 @@
 // 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,13 +44,15 @@
 }
 #endif
 
+#ifndef _OPENCL_H_
 int isnan(float x) {
 return __builtin_isnan(x);
 }
 
 int isfinite(float x) {
 return __builtin_isfinite(x);
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64
Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -506,10 +506,12 @@
   // 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)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits