[PATCH] D105892: [NFC] Silence build warning by placing parentheses around condition

Anton Zabaznov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 13 07:48:13 PDT 2021


azabaznov updated this revision to Diff 358265.
azabaznov added a comment.

Add comment for C++ for OpenCL, add variable to check support for OpenCL C


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105892/new/

https://reviews.llvm.org/D105892

Files:
  clang/lib/Sema/SemaDeclAttr.cpp


Index: clang/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7402,14 +7402,17 @@
   // OpenCL v3.0 s6.8 - For OpenCL C 2.0, or with the
   // __opencl_c_read_write_images feature, image objects specified as arguments
   // to a kernel can additionally be declared to be read-write.
+  // C++ for OpenCL inherits rule from OpenCL C v2.0.
   if (const auto *PDecl = dyn_cast<ParmVarDecl>(D)) {
     const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
     if (AL.getAttrName()->getName().find("read_write") != StringRef::npos) {
-      if (((!S.getLangOpts().OpenCLCPlusPlus &&
-            (S.getLangOpts().OpenCLVersion < 200)) ||
-           (S.getLangOpts().OpenCLVersion == 300 &&
-            !S.getOpenCLOptions().isSupported("__opencl_c_read_write_images",
-                                              S.getLangOpts()))) ||
+      bool ReadWriteImagesUnsupportedForOCLC =
+          (S.getLangOpts().OpenCLVersion < 200) ||
+          (S.getLangOpts().OpenCLVersion == 300 &&
+           !S.getOpenCLOptions().isSupported("__opencl_c_read_write_images",
+                                             S.getLangOpts()));
+      if ((!S.getLangOpts().OpenCLCPlusPlus &&
+           ReadWriteImagesUnsupportedForOCLC) ||
           DeclTy->isPipeType()) {
         S.Diag(AL.getLoc(), diag::err_opencl_invalid_read_write)
             << AL << PDecl->getType() << DeclTy->isImageType();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105892.358265.patch
Type: text/x-patch
Size: 1532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210713/ad51e25c/attachment.bin>


More information about the cfe-commits mailing list