[llvm-branch-commits] [cfe-branch] r353826 - Merging r353431:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Feb 12 03:02:45 PST 2019
Author: hans
Date: Tue Feb 12 03:02:43 2019
New Revision: 353826
URL: http://llvm.org/viewvc/llvm-project?rev=353826&view=rev
Log:
Merging r353431:
------------------------------------------------------------------------
r353431 | stulova | 2019-02-07 18:32:37 +0100 (Thu, 07 Feb 2019) | 9 lines
[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/branches/release_80/ (props changed)
cfe/branches/release_80/include/clang/Basic/OpenCLOptions.h
cfe/branches/release_80/lib/Frontend/InitPreprocessor.cpp
cfe/branches/release_80/lib/Parse/ParsePragma.cpp
cfe/branches/release_80/lib/Sema/Sema.cpp
cfe/branches/release_80/test/SemaOpenCL/extension-version.cl
cfe/branches/release_80/test/SemaOpenCL/extensions.cl
Propchange: cfe/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 12 03:02:43 2019
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:351334,351340,351344,351360,351457,351459,351531,351579-351580,352040,352079,352099,352102,352105,352156,352221-352222,352229,352307,352323,352463,352539,352610,352672,352822,353142,353393,353411,353495
+/cfe/trunk:351334,351340,351344,351360,351457,351459,351531,351579-351580,352040,352079,352099,352102,352105,352156,352221-352222,352229,352307,352323,352463,352539,352610,352672,352822,353142,353393,353411,353431,353495
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_80/include/clang/Basic/OpenCLOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/include/clang/Basic/OpenCLOptions.h?rev=353826&r1=353825&r2=353826&view=diff
==============================================================================
--- cfe/branches/release_80/include/clang/Basic/OpenCLOptions.h (original)
+++ cfe/branches/release_80/include/clang/Basic/OpenCLOptions.h Tue Feb 12 03:02:43 2019
@@ -15,6 +15,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 {
@@ -42,25 +43,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) {
@@ -122,10 +127,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;
}
@@ -133,6 +138,6 @@ public:
friend class ASTReader;
};
-} // end namespace clang
+} // end namespace clang
#endif
Modified: cfe/branches/release_80/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/Frontend/InitPreprocessor.cpp?rev=353826&r1=353825&r2=353826&view=diff
==============================================================================
--- cfe/branches/release_80/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/branches/release_80/lib/Frontend/InitPreprocessor.cpp Tue Feb 12 03:02:43 2019
@@ -1059,10 +1059,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/branches/release_80/lib/Parse/ParsePragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/Parse/ParsePragma.cpp?rev=353826&r1=353825&r2=353826&view=diff
==============================================================================
--- cfe/branches/release_80/lib/Parse/ParsePragma.cpp (original)
+++ cfe/branches/release_80/lib/Parse/ParsePragma.cpp Tue Feb 12 03:02:43 2019
@@ -693,13 +693,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);
@@ -709,9 +708,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/branches/release_80/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/Sema/Sema.cpp?rev=353826&r1=353825&r2=353826&view=diff
==============================================================================
--- cfe/branches/release_80/lib/Sema/Sema.cpp (original)
+++ cfe/branches/release_80/lib/Sema/Sema.cpp Tue Feb 12 03:02:43 2019
@@ -256,11 +256,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/branches/release_80/test/SemaOpenCL/extension-version.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/test/SemaOpenCL/extension-version.cl?rev=353826&r1=353825&r2=353826&view=diff
==============================================================================
--- cfe/branches/release_80/test/SemaOpenCL/extension-version.cl (original)
+++ cfe/branches/release_80/test/SemaOpenCL/extension-version.cl Tue Feb 12 03:02:43 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 at -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 at -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 at -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 at -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 at -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 at -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 at -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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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/branches/release_80/test/SemaOpenCL/extensions.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/test/SemaOpenCL/extensions.cl?rev=353826&r1=353825&r2=353826&view=diff
==============================================================================
--- cfe/branches/release_80/test/SemaOpenCL/extensions.cl (original)
+++ cfe/branches/release_80/test/SemaOpenCL/extensions.cl Tue Feb 12 03:02:43 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 at -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}}
}
More information about the llvm-branch-commits
mailing list