Merged to 8.0 in r353826.
On Thu, Feb 7, 2019 at 6:32 PM Anastasia Stulova via cfe-commits <cfe-commits@lists.llvm.org> wrote: > > Author: stulova > Date: Thu Feb 7 09:32:37 2019 > New Revision: 353431 > > URL: http://llvm.org/viewvc/llvm-project?rev=353431&view=rev > Log: > [OpenCL][PR40603] In C++ preserve compatibility with OpenCL C v2.0 > > Valid OpenCL C code should still compile in C++ mode. > > This change enables extensions and OpenCL types. > > Differential Revision: https://reviews.llvm.org/D57824 > > > Modified: > cfe/trunk/include/clang/Basic/OpenCLOptions.h > cfe/trunk/lib/Frontend/InitPreprocessor.cpp > cfe/trunk/lib/Parse/ParsePragma.cpp > cfe/trunk/lib/Sema/Sema.cpp > cfe/trunk/test/SemaOpenCL/extension-version.cl > cfe/trunk/test/SemaOpenCL/extensions.cl > > Modified: cfe/trunk/include/clang/Basic/OpenCLOptions.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLOptions.h?rev=353431&r1=353430&r2=353431&view=diff > ============================================================================== > --- cfe/trunk/include/clang/Basic/OpenCLOptions.h (original) > +++ cfe/trunk/include/clang/Basic/OpenCLOptions.h Thu Feb 7 09:32:37 2019 > @@ -14,6 +14,7 @@ > #ifndef LLVM_CLANG_BASIC_OPENCLOPTIONS_H > #define LLVM_CLANG_BASIC_OPENCLOPTIONS_H > > +#include "clang/Basic/LangOptions.h" > #include "llvm/ADT/StringMap.h" > > namespace clang { > @@ -41,25 +42,29 @@ public: > > // Is supported as either an extension or an (optional) core feature for > // OpenCL version \p CLVer. > - bool isSupported(llvm::StringRef Ext, unsigned CLVer) const { > + bool isSupported(llvm::StringRef Ext, LangOptions LO) const { > + // In C++ mode all extensions should work at least as in v2.0. > + auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; > auto I = OptMap.find(Ext)->getValue(); > return I.Supported && I.Avail <= CLVer; > } > > // Is supported (optional) OpenCL core features for OpenCL version \p > CLVer. > // For supported extension, return false. > - bool isSupportedCore(llvm::StringRef Ext, unsigned CLVer) const { > + bool isSupportedCore(llvm::StringRef Ext, LangOptions LO) const { > + // In C++ mode all extensions should work at least as in v2.0. > + auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; > auto I = OptMap.find(Ext)->getValue(); > - return I.Supported && I.Avail <= CLVer && > - I.Core != ~0U && CLVer >= I.Core; > + return I.Supported && I.Avail <= CLVer && I.Core != ~0U && CLVer >= > I.Core; > } > > // Is supported OpenCL extension for OpenCL version \p CLVer. > // For supported (optional) core feature, return false. > - bool isSupportedExtension(llvm::StringRef Ext, unsigned CLVer) const { > + bool isSupportedExtension(llvm::StringRef Ext, LangOptions LO) const { > + // In C++ mode all extensions should work at least as in v2.0. > + auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; > auto I = OptMap.find(Ext)->getValue(); > - return I.Supported && I.Avail <= CLVer && > - (I.Core == ~0U || CLVer < I.Core); > + return I.Supported && I.Avail <= CLVer && (I.Core == ~0U || CLVer < > I.Core); > } > > void enable(llvm::StringRef Ext, bool V = true) { > @@ -121,10 +126,10 @@ public: > I->second.Enabled = false; > } > > - void enableSupportedCore(unsigned CLVer) { > - for (llvm::StringMap<Info>::iterator I = OptMap.begin(), > - E = OptMap.end(); I != E; ++I) > - if (isSupportedCore(I->getKey(), CLVer)) > + void enableSupportedCore(LangOptions LO) { > + for (llvm::StringMap<Info>::iterator I = OptMap.begin(), E = > OptMap.end(); > + I != E; ++I) > + if (isSupportedCore(I->getKey(), LO)) > I->second.Enabled = true; > } > > @@ -132,6 +137,6 @@ public: > friend class ASTReader; > }; > > -} // end namespace clang > +} // end namespace clang > > #endif > > Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=353431&r1=353430&r2=353431&view=diff > ============================================================================== > --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) > +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu Feb 7 09:32:37 2019 > @@ -1058,10 +1058,9 @@ static void InitializePredefinedMacros(c > > // OpenCL definitions. > if (LangOpts.OpenCL) { > -#define OPENCLEXT(Ext) \ > - if (TI.getSupportedOpenCLOpts().isSupported(#Ext, \ > - LangOpts.OpenCLVersion)) \ > - Builder.defineMacro(#Ext); > +#define OPENCLEXT(Ext) > \ > + if (TI.getSupportedOpenCLOpts().isSupported(#Ext, LangOpts)) > \ > + Builder.defineMacro(#Ext); > #include "clang/Basic/OpenCLExtensions.def" > > auto Arch = TI.getTriple().getArch(); > > Modified: cfe/trunk/lib/Parse/ParsePragma.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=353431&r1=353430&r2=353431&view=diff > ============================================================================== > --- cfe/trunk/lib/Parse/ParsePragma.cpp (original) > +++ cfe/trunk/lib/Parse/ParsePragma.cpp Thu Feb 7 09:32:37 2019 > @@ -692,13 +692,12 @@ void Parser::HandlePragmaOpenCLExtension > if (Name == "all") { > if (State == Disable) { > Opt.disableAll(); > - Opt.enableSupportedCore(getLangOpts().OpenCLVersion); > + Opt.enableSupportedCore(getLangOpts()); > } else { > PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1; > } > } else if (State == Begin) { > - if (!Opt.isKnown(Name) || > - !Opt.isSupported(Name, getLangOpts().OpenCLVersion)) { > + if (!Opt.isKnown(Name) || !Opt.isSupported(Name, getLangOpts())) { > Opt.support(Name); > } > Actions.setCurrentOpenCLExtension(Name); > @@ -708,9 +707,9 @@ void Parser::HandlePragmaOpenCLExtension > Actions.setCurrentOpenCLExtension(""); > } else if (!Opt.isKnown(Name)) > PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << Ident; > - else if (Opt.isSupportedExtension(Name, getLangOpts().OpenCLVersion)) > + else if (Opt.isSupportedExtension(Name, getLangOpts())) > Opt.enable(Name, State == Enable); > - else if (Opt.isSupportedCore(Name, getLangOpts().OpenCLVersion)) > + else if (Opt.isSupportedCore(Name, getLangOpts())) > PP.Diag(NameLoc, diag::warn_pragma_extension_is_core) << Ident; > else > PP.Diag(NameLoc, diag::warn_pragma_unsupported_extension) << Ident; > > Modified: cfe/trunk/lib/Sema/Sema.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=353431&r1=353430&r2=353431&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/Sema.cpp (original) > +++ cfe/trunk/lib/Sema/Sema.cpp Thu Feb 7 09:32:37 2019 > @@ -255,11 +255,12 @@ void Sema::Initialize() { > // Initialize predefined OpenCL types and supported extensions and > (optional) > // core features. > if (getLangOpts().OpenCL) { > - > getOpenCLOptions().addSupport(Context.getTargetInfo().getSupportedOpenCLOpts()); > - getOpenCLOptions().enableSupportedCore(getLangOpts().OpenCLVersion); > + getOpenCLOptions().addSupport( > + Context.getTargetInfo().getSupportedOpenCLOpts()); > + getOpenCLOptions().enableSupportedCore(getLangOpts()); > addImplicitTypedef("sampler_t", Context.OCLSamplerTy); > addImplicitTypedef("event_t", Context.OCLEventTy); > - if (getLangOpts().OpenCLVersion >= 200) { > + if (getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) > { > addImplicitTypedef("clk_event_t", Context.OCLClkEventTy); > addImplicitTypedef("queue_t", Context.OCLQueueTy); > addImplicitTypedef("reserve_id_t", Context.OCLReserveIDTy); > > Modified: cfe/trunk/test/SemaOpenCL/extension-version.cl > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extension-version.cl?rev=353431&r1=353430&r2=353431&view=diff > ============================================================================== > --- cfe/trunk/test/SemaOpenCL/extension-version.cl (original) > +++ cfe/trunk/test/SemaOpenCL/extension-version.cl Thu Feb 7 09:32:37 2019 > @@ -2,12 +2,14 @@ > // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple > spir-unknown-unknown > // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple > spir-unknown-unknown > // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple > spir-unknown-unknown > +// RUN: %clang_cc1 -x cl -cl-std=c++ %s -verify -triple spir-unknown-unknown > // RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown > -Wpedantic-core-features -DTEST_CORE_FEATURES > // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple > spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES > // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple > spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES > // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple > spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES > +// RUN: %clang_cc1 -x cl -cl-std=c++ %s -verify -triple spir-unknown-unknown > -Wpedantic-core-features -DTEST_CORE_FEATURES > > -#if __OPENCL_C_VERSION__ >= 200 && ! defined TEST_CORE_FEATURES > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && > !defined(TEST_CORE_FEATURES) > // expected-no-diagnostics > #endif > > @@ -47,44 +49,44 @@ > #ifndef cl_khr_byte_addressable_store > #error "Missing cl_khr_byte_addressable_store define" > #endif > -#pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable > -#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES > +#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && > defined TEST_CORE_FEATURES > // expected-warning@-2{{OpenCL extension 'cl_khr_byte_addressable_store' is > core feature or supported optional core feature - ignoring}} > #endif > > #ifndef cl_khr_global_int32_base_atomics > #error "Missing cl_khr_global_int32_base_atomics define" > #endif > -#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable > -#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES > +#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && > defined TEST_CORE_FEATURES > // expected-warning@-2{{OpenCL extension 'cl_khr_global_int32_base_atomics' > is core feature or supported optional core feature - ignoring}} > #endif > > #ifndef cl_khr_global_int32_extended_atomics > #error "Missing cl_khr_global_int32_extended_atomics define" > #endif > -#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics: enable > -#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES > +#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics : enable > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && > defined TEST_CORE_FEATURES > // expected-warning@-2{{OpenCL extension > 'cl_khr_global_int32_extended_atomics' is core feature or supported optional > core feature - ignoring}} > #endif > > #ifndef cl_khr_local_int32_base_atomics > #error "Missing cl_khr_local_int32_base_atomics define" > #endif > -#pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics: enable > -#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES > +#pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics : enable > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && > defined TEST_CORE_FEATURES > // expected-warning@-2{{OpenCL extension 'cl_khr_local_int32_base_atomics' > is core feature or supported optional core feature - ignoring}} > #endif > > #ifndef cl_khr_local_int32_extended_atomics > #error "Missing cl_khr_local_int32_extended_atomics define" > #endif > -#pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics: enable > -#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES > +#pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics : enable > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && > defined TEST_CORE_FEATURES > // expected-warning@-2{{OpenCL extension > 'cl_khr_local_int32_extended_atomics' is core feature or supported optional > core feature - ignoring}} > #endif > > -#if (__OPENCL_C_VERSION__ < 110) > +#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 110) > // Deprecated abvoe 1.0 > #ifndef cl_khr_select_fprounding_mode > #error "Missing cl_khr_select_fp_rounding_mode define" > @@ -97,8 +99,8 @@ > #ifndef cl_khr_fp64 > #error "Missing cl_khr_fp64 define" > #endif > -#pragma OPENCL EXTENSION cl_khr_fp64: enable > -#if (__OPENCL_C_VERSION__ >= 120) && defined TEST_CORE_FEATURES > +#pragma OPENCL EXTENSION cl_khr_fp64 : enable > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) && > defined TEST_CORE_FEATURES > // expected-warning@-2{{OpenCL extension 'cl_khr_fp64' is core feature or > supported optional core feature - ignoring}} > #endif > > @@ -106,131 +108,129 @@ > #ifndef cl_khr_3d_image_writes > #error "Missing cl_khr_3d_image_writes define" > #endif > -#pragma OPENCL EXTENSION cl_khr_3d_image_writes: enable > -#if (__OPENCL_C_VERSION__ >= 200) && defined TEST_CORE_FEATURES > +#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && > defined TEST_CORE_FEATURES > // expected-warning@-2{{OpenCL extension 'cl_khr_3d_image_writes' is core > feature or supported optional core feature - ignoring}} > #endif > > - > - > -#if (__OPENCL_C_VERSION__ >= 110) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) > #ifndef cl_khr_gl_event > #error "Missing cl_khr_gl_event define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_gl_event' - > ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_gl_event: enable > +#pragma OPENCL EXTENSION cl_khr_gl_event : enable > > -#if (__OPENCL_C_VERSION__ >= 110) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) > #ifndef cl_khr_d3d10_sharing > #error "Missing cl_khr_d3d10_sharing define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_d3d10_sharing' > - ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_d3d10_sharing: enable > +#pragma OPENCL EXTENSION cl_khr_d3d10_sharing : enable > > -#if (__OPENCL_C_VERSION__ >= 110) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) > #ifndef cles_khr_int64 > #error "Missing cles_khr_int64 define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension 'cles_khr_int64' - > ignoring}} > #endif > -#pragma OPENCL EXTENSION cles_khr_int64: enable > +#pragma OPENCL EXTENSION cles_khr_int64 : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_khr_context_abort > #error "Missing cl_context_abort define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_context_abort' > - ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_context_abort: enable > +#pragma OPENCL EXTENSION cl_khr_context_abort : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_khr_d3d11_sharing > #error "Missing cl_khr_d3d11_sharing define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_d3d11_sharing' > - ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_d3d11_sharing: enable > +#pragma OPENCL EXTENSION cl_khr_d3d11_sharing : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_khr_dx9_media_sharing > #error "Missing cl_khr_dx9_media_sharing define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension > 'cl_khr_dx9_media_sharing' - ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_dx9_media_sharing: enable > +#pragma OPENCL EXTENSION cl_khr_dx9_media_sharing : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_khr_image2d_from_buffer > #error "Missing cl_khr_image2d_from_buffer define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension > 'cl_khr_image2d_from_buffer' - ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_image2d_from_buffer: enable > +#pragma OPENCL EXTENSION cl_khr_image2d_from_buffer : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_khr_initialize_memory > #error "Missing cl_khr_initialize_memory define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension > 'cl_khr_initialize_memory' - ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_initialize_memory: enable > +#pragma OPENCL EXTENSION cl_khr_initialize_memory : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_khr_gl_depth_images > #error "Missing cl_khr_gl_depth_images define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension > 'cl_khr_gl_depth_images' - ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_gl_depth_images: enable > +#pragma OPENCL EXTENSION cl_khr_gl_depth_images : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_khr_gl_msaa_sharing > #error "Missing cl_khr_gl_msaa_sharing define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension > 'cl_khr_gl_msaa_sharing' - ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing: enable > +#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_khr_spir > #error "Missing cl_khr_spir define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_spir' - > ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_spir: enable > +#pragma OPENCL EXTENSION cl_khr_spir : enable > > -#if (__OPENCL_C_VERSION__ >= 200) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) > #ifndef cl_khr_egl_event > #error "Missing cl_khr_egl_event define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_egl_event' - > ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_egl_event: enable > +#pragma OPENCL EXTENSION cl_khr_egl_event : enable > > -#if (__OPENCL_C_VERSION__ >= 200) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) > #ifndef cl_khr_egl_image > #error "Missing cl_khr_egl_image define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_egl_image' - > ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_egl_image: enable > +#pragma OPENCL EXTENSION cl_khr_egl_image : enable > > -#if (__OPENCL_C_VERSION__ >= 200) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) > #ifndef cl_khr_mipmap_image > #error "Missing cl_khr_mipmap_image define" > #endif > @@ -240,18 +240,18 @@ > #endif > // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - > ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable > +#pragma OPENCL EXTENSION cl_khr_mipmap_image : enable > > -#if (__OPENCL_C_VERSION__ >= 200) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) > #ifndef cl_khr_srgb_image_writes > #error "Missing cl_khr_srgb_image_writes define" > #endif > #else > // expected-warning@+2{{unsupported OpenCL extension > 'cl_khr_srgb_image_writes' - ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_srgb_image_writes: enable > +#pragma OPENCL EXTENSION cl_khr_srgb_image_writes : enable > > -#if (__OPENCL_C_VERSION__ >= 200) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) > #ifndef cl_khr_subgroups > #error "Missing cl_khr_subgroups define" > #endif > @@ -261,9 +261,9 @@ > #endif > // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - > ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_subgroups: enable > +#pragma OPENCL EXTENSION cl_khr_subgroups : enable > > -#if (__OPENCL_C_VERSION__ >= 200) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) > #ifndef cl_khr_terminate_context > #error "Missing cl_khr_terminate_context define" > #endif > @@ -280,9 +280,9 @@ > #ifndef cl_amd_media_ops2 > #error "Missing cl_amd_media_ops2 define" > #endif > -#pragma OPENCL EXTENSION cl_amd_media_ops2: enable > +#pragma OPENCL EXTENSION cl_amd_media_ops2 : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_khr_depth_images > #error "Missing cl_khr_depth_images define" > #endif > @@ -292,9 +292,9 @@ > #endif > // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_depth_images' - > ignoring}} > #endif > -#pragma OPENCL EXTENSION cl_khr_depth_images: enable > +#pragma OPENCL EXTENSION cl_khr_depth_images : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_intel_subgroups > #error "Missing cl_intel_subgroups define" > #endif > @@ -303,7 +303,7 @@ > #endif > #pragma OPENCL EXTENSION cl_intel_subgroups : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_intel_subgroups_short > #error "Missing cl_intel_subgroups_short define" > #endif > @@ -312,7 +312,7 @@ > #endif > #pragma OPENCL EXTENSION cl_intel_subgroups_short : enable > > -#if (__OPENCL_C_VERSION__ >= 120) > +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) > #ifndef cl_intel_device_side_avc_motion_estimation > #error "Missing cl_intel_device_side_avc_motion_estimation define" > #endif > > Modified: cfe/trunk/test/SemaOpenCL/extensions.cl > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extensions.cl?rev=353431&r1=353430&r2=353431&view=diff > ============================================================================== > --- cfe/trunk/test/SemaOpenCL/extensions.cl (original) > +++ cfe/trunk/test/SemaOpenCL/extensions.cl Thu Feb 7 09:32:37 2019 > @@ -28,6 +28,7 @@ > // 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 > +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic > -fsyntax-only -cl-std=c++ > > #ifdef _OPENCL_H_ > // expected-no-diagnostics > @@ -37,7 +38,11 @@ > // expected-no-diagnostics > #endif > > -#if __OPENCL_C_VERSION__ < 120 > +#ifdef __OPENCL_CPP_VERSION__ > +// expected-no-diagnostics > +#endif > + > +#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120) > void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 > extension}} > double d; // expected-error {{type 'double' requires cl_khr_fp64 > extension}} > (void) 1.0; // expected-warning {{double precision constant requires > cl_khr_fp64}} > @@ -89,7 +94,7 @@ void f2(void) { > // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - > ignoring}} > #endif > > -#if __OPENCL_C_VERSION__ < 120 > +#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120) > void f3(void) { > double d; // expected-error {{type 'double' requires cl_khr_fp64 > extension}} > } > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits