From 03d8fed34951bc6e92b36615ec3afe6f36d10de6 Mon Sep 17 00:00:00 2001 From: Anton Zabaznov Date: Tue, 13 Jul 2021 16:41:21 +0300 Subject: [PATCH] [OpenCL] Add verbosity when checking support of read_write images Parenthesis were fixed incorrectly by D105890 Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D105892 --- clang/lib/Sema/SemaDeclAttr.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index a5d0597..3586ad3 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -7402,14 +7402,17 @@ static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // 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(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(); -- 2.7.4