| 1 |
From ab0cfa1b9caa016cac1ea7de885b32ab7ce043d2 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Wenju He <[email protected]> |
| 3 |
Date: Tue, 14 Jul 2026 14:21:00 +0200 |
| 4 |
Subject: [PATCH 2/2] [OpenCL] Fix extensions checks for 3.1 (#208370) |
| 5 |
|
| 6 |
These extension checks apply to 3.1 as well. |
| 7 |
This fix kernel build fails when OpenCL 3.1 is enabled in |
| 8 |
https://github.com/intel/opencl-clang/pull/752 |
| 9 |
|
| 10 |
Assisted-by: Claude |
| 11 |
--- |
| 12 |
clang/include/clang/Basic/OpenCLOptions.h | 2 +- |
| 13 |
clang/lib/Sema/SemaDeclAttr.cpp | 2 +- |
| 14 |
clang/lib/Sema/SemaType.cpp | 4 +-- |
| 15 |
clang/test/SemaOpenCL/access-qualifier.cl | 12 +++++---- |
| 16 |
clang/test/SemaOpenCL/fp64-fp16-options.cl | 7 +++++ |
| 17 |
clang/test/SemaOpenCL/storageclass.cl | 30 ++++++++++++---------- |
| 18 |
clang/test/SemaOpenCL/unsupported-image.cl | 3 +++ |
| 19 |
7 files changed, 38 insertions(+), 22 deletions(-) |
| 20 |
|
| 21 |
diff --git a/clang/include/clang/Basic/OpenCLOptions.h b/clang/include/clang/Basic/OpenCLOptions.h |
| 22 |
index ec661bba94ad..915aad94cc5b 100644 |
| 23 |
--- a/clang/include/clang/Basic/OpenCLOptions.h |
| 24 |
+++ b/clang/include/clang/Basic/OpenCLOptions.h |
| 25 |
@@ -83,7 +83,7 @@ public: |
| 26 |
// C++ for OpenCL inherits rule from OpenCL C v2.0. |
| 27 |
bool areProgramScopeVariablesSupported(const LangOptions &Opts) const { |
| 28 |
return Opts.getOpenCLCompatibleVersion() == 200 || |
| 29 |
- (Opts.getOpenCLCompatibleVersion() == 300 && |
| 30 |
+ (Opts.getOpenCLCompatibleVersion() >= 300 && |
| 31 |
isSupported("__opencl_c_program_scope_global_variables", Opts)); |
| 32 |
} |
| 33 |
|
| 34 |
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp |
| 35 |
index 61242e69a33e..8e13a26085e1 100644 |
| 36 |
--- a/clang/lib/Sema/SemaDeclAttr.cpp |
| 37 |
+++ b/clang/lib/Sema/SemaDeclAttr.cpp |
| 38 |
@@ -8199,7 +8199,7 @@ static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) { |
| 39 |
if (AL.getAttrName()->getName().contains("read_write")) { |
| 40 |
bool ReadWriteImagesUnsupported = |
| 41 |
(S.getLangOpts().getOpenCLCompatibleVersion() < 200) || |
| 42 |
- (S.getLangOpts().getOpenCLCompatibleVersion() == 300 && |
| 43 |
+ (S.getLangOpts().getOpenCLCompatibleVersion() >= 300 && |
| 44 |
!S.getOpenCLOptions().isSupported("__opencl_c_read_write_images", S.getLangOpts()) && |
| 45 |
!S.getASTContext().getTargetInfo().getTriple().isSPIR() && |
| 46 |
!S.getASTContext().getTargetInfo().getTriple().isSPIRV()); |
| 47 |
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp |
| 48 |
index b5c35daf7c33..99926cfe1182 100644 |
| 49 |
--- a/clang/lib/Sema/SemaType.cpp |
| 50 |
+++ b/clang/lib/Sema/SemaType.cpp |
| 51 |
@@ -1533,7 +1533,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { |
| 52 |
if (!S.getOpenCLOptions().isSupported("cl_khr_fp64", S.getLangOpts())) |
| 53 |
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension) |
| 54 |
<< 0 << Result |
| 55 |
- << (S.getLangOpts().getOpenCLCompatibleVersion() == 300 |
| 56 |
+ << (S.getLangOpts().getOpenCLCompatibleVersion() >= 300 |
| 57 |
? "cl_khr_fp64 and __opencl_c_fp64" |
| 58 |
: "cl_khr_fp64"); |
| 59 |
else if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp64", S.getLangOpts())) |
| 60 |
@@ -1743,7 +1743,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { |
| 61 |
if (S.getLangOpts().OpenCL) { |
| 62 |
const auto &OpenCLOptions = S.getOpenCLOptions(); |
| 63 |
bool IsOpenCLC30Compatible = |
| 64 |
- S.getLangOpts().getOpenCLCompatibleVersion() == 300; |
| 65 |
+ S.getLangOpts().getOpenCLCompatibleVersion() >= 300; |
| 66 |
// OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images |
| 67 |
// support. |
| 68 |
// OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support |
| 69 |
diff --git a/clang/test/SemaOpenCL/access-qualifier.cl b/clang/test/SemaOpenCL/access-qualifier.cl |
| 70 |
index 726253c0b1a2..3ba6fefc5456 100644 |
| 71 |
--- a/clang/test/SemaOpenCL/access-qualifier.cl |
| 72 |
+++ b/clang/test/SemaOpenCL/access-qualifier.cl |
| 73 |
@@ -2,6 +2,8 @@ |
| 74 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s |
| 75 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s |
| 76 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s -cl-ext=-__opencl_c_read_write_images |
| 77 |
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.1 %s |
| 78 |
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.1 %s -cl-ext=-__opencl_c_read_write_images |
| 79 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++2021 %s |
| 80 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++2021 %s -cl-ext=-__opencl_c_read_write_images |
| 81 |
|
| 82 |
@@ -10,7 +12,7 @@ typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read |
| 83 |
typedef write_only image1d_t img1d_wo; // expected-note {{previously declared 'write_only' here}} |
| 84 |
typedef read_only image1d_t img1d_ro; |
| 85 |
|
| 86 |
-#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images)) |
| 87 |
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ >= 300) && defined(__opencl_c_read_write_images)) |
| 88 |
typedef read_write image1d_t img1d_rw; |
| 89 |
#endif |
| 90 |
|
| 91 |
@@ -33,7 +35,7 @@ void myRead(read_only image1d_t); |
| 92 |
// expected-note@-4 {{candidate function not viable: no known conversion from '__private img1d_wo' (aka '__private __write_only image1d_t') to '__private __read_only image1d_t' for 1st argument}} |
| 93 |
#endif |
| 94 |
|
| 95 |
-#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images)) |
| 96 |
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ >= 300) && defined(__opencl_c_read_write_images)) |
| 97 |
void myReadWrite(read_write image1d_t); |
| 98 |
#else |
| 99 |
void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 'read_write' can not be used for '__read_write image1d_t' prior to OpenCL C version 2.0 or in version 3.0 and without __opencl_c_read_write_images feature}} |
| 100 |
@@ -62,7 +64,7 @@ kernel void k3(img1d_wo img) { |
| 101 |
myWrite(img); |
| 102 |
} |
| 103 |
|
| 104 |
-#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images)) |
| 105 |
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ >= 300) && defined(__opencl_c_read_write_images)) |
| 106 |
kernel void k4(img1d_rw img) { |
| 107 |
myReadWrite(img); |
| 108 |
} |
| 109 |
@@ -93,7 +95,7 @@ kernel void k11(read_only write_only image1d_t i){} // expected-error{{multiple |
| 110 |
|
| 111 |
kernel void k12(read_only read_only image1d_t i){} // expected-warning {{duplicate 'read_only' declaration specifier}} |
| 112 |
|
| 113 |
-#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images)) |
| 114 |
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ >= 300) && defined(__opencl_c_read_write_images)) |
| 115 |
kernel void k13(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'read_only pipe int'}} |
| 116 |
#else |
| 117 |
kernel void k13(__read_write image1d_t i){} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' prior to OpenCL C version 2.0 or in version 3.0 and without __opencl_c_read_write_images feature}} |
| 118 |
@@ -103,7 +105,7 @@ kernel void k13(__read_write image1d_t i){} // expected-error{{access qualifier |
| 119 |
kernel void test_image3d_wo(write_only image3d_t img) {} // expected-error {{use of type '__write_only image3d_t' requires cl_khr_3d_image_writes support}} |
| 120 |
#endif |
| 121 |
|
| 122 |
-#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images)) |
| 123 |
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ >= 300) && defined(__opencl_c_read_write_images)) |
| 124 |
kernel void read_write_twice_typedef(read_write img1d_rw i){} // expected-warning {{duplicate 'read_write' declaration specifier}} |
| 125 |
// expected-note@-94 {{previously declared 'read_write' here}} |
| 126 |
#endif |
| 127 |
diff --git a/clang/test/SemaOpenCL/fp64-fp16-options.cl b/clang/test/SemaOpenCL/fp64-fp16-options.cl |
| 128 |
index cee430ca9ef0..34610c8b4f83 100644 |
| 129 |
--- a/clang/test/SemaOpenCL/fp64-fp16-options.cl |
| 130 |
+++ b/clang/test/SemaOpenCL/fp64-fp16-options.cl |
| 131 |
@@ -6,6 +6,7 @@ |
| 132 |
// Test with a target not supporting fp64. |
| 133 |
// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16 |
| 134 |
// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16 |
| 135 |
+// RUN: %clang_cc1 -cl-std=CL3.1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16 |
| 136 |
// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16 |
| 137 |
|
| 138 |
// Test with some extensions enabled or disabled by cmd-line args |
| 139 |
@@ -21,6 +22,9 @@ |
| 140 |
// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16 |
| 141 |
// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64 |
| 142 |
// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64 |
| 143 |
+// RUN: %clang_cc1 -cl-std=CL3.1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16 |
| 144 |
+// RUN: %clang_cc1 -cl-std=CL3.1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64 |
| 145 |
+// RUN: %clang_cc1 -cl-std=CL3.1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64 |
| 146 |
// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16 |
| 147 |
// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64 |
| 148 |
// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64 |
| 149 |
@@ -33,6 +37,9 @@ |
| 150 |
// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64 |
| 151 |
// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64 |
| 152 |
// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64 |
| 153 |
+// RUN: %clang_cc1 -cl-std=CL3.1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64 |
| 154 |
+// RUN: %clang_cc1 -cl-std=CL3.1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64 |
| 155 |
+// RUN: %clang_cc1 -cl-std=CL3.1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64 |
| 156 |
// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64 |
| 157 |
// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64 |
| 158 |
// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64 |
| 159 |
diff --git a/clang/test/SemaOpenCL/storageclass.cl b/clang/test/SemaOpenCL/storageclass.cl |
| 160 |
index 4b9d6e9dd4f2..64dc71619866 100644 |
| 161 |
--- a/clang/test/SemaOpenCL/storageclass.cl |
| 162 |
+++ b/clang/test/SemaOpenCL/storageclass.cl |
| 163 |
@@ -3,6 +3,10 @@ |
| 164 |
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_program_scope_global_variables |
| 165 |
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_generic_address_space |
| 166 |
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space |
| 167 |
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.1 -cl-ext=-all |
| 168 |
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.1 -cl-ext=-all,+__opencl_c_program_scope_global_variables |
| 169 |
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.1 -cl-ext=-all,+__opencl_c_generic_address_space |
| 170 |
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.1 -cl-ext=-all,+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space |
| 171 |
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-all |
| 172 |
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-all,+__opencl_c_program_scope_global_variables |
| 173 |
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-all,+__opencl_c_generic_address_space |
| 174 |
@@ -50,10 +54,10 @@ static generic float g_generic_static_var = 0; |
| 175 |
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) |
| 176 |
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}} |
| 177 |
// expected-error@-3 {{program scope variable must reside in constant address space}} |
| 178 |
-#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) |
| 179 |
+#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ >= 300) |
| 180 |
#if !defined(__opencl_c_generic_address_space) |
| 181 |
-#if (__OPENCL_C_VERSION__ == 300) |
| 182 |
-// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}} |
| 183 |
+#if (__OPENCL_C_VERSION__ >= 300) |
| 184 |
+// expected-error-re@-7 {{OpenCL C version {{3.0|3.1}} does not support the 'generic' type qualifier}} |
| 185 |
#elif (__OPENCL_CPP_VERSION__ == 202100) |
| 186 |
// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}} |
| 187 |
#endif |
| 188 |
@@ -96,10 +100,10 @@ extern generic float g_generic_extern_var; |
| 189 |
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) |
| 190 |
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}} |
| 191 |
// expected-error@-3 {{extern variable must reside in constant address space}} |
| 192 |
-#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) |
| 193 |
+#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ >= 300) |
| 194 |
#if !defined(__opencl_c_generic_address_space) |
| 195 |
-#if (__OPENCL_C_VERSION__ == 300) |
| 196 |
-// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}} |
| 197 |
+#if (__OPENCL_C_VERSION__ >= 300) |
| 198 |
+// expected-error-re@-7 {{OpenCL C version {{3.0|3.1}} does not support the 'generic' type qualifier}} |
| 199 |
#elif (__OPENCL_CPP_VERSION__ == 202100) |
| 200 |
// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}} |
| 201 |
#endif |
| 202 |
@@ -138,7 +142,7 @@ void kernel foo(int x) { |
| 203 |
#if (__OPENCL_CPP_VERSION__ == 202100) |
| 204 |
// expected-error@-2{{C++ for OpenCL version 2021 does not support the 'auto' storage class specifier}} |
| 205 |
#else |
| 206 |
-// expected-error-re@-4{{OpenCL C version {{1.2|3.0}} does not support the 'auto' storage class specifier}} |
| 207 |
+// expected-error-re@-4{{OpenCL C version {{1.2|3.0|3.1}} does not support the 'auto' storage class specifier}} |
| 208 |
#endif |
| 209 |
global int L4; // expected-error{{function scope variable cannot be declared in global address space}} |
| 210 |
__attribute__((address_space(100))) int L5; // expected-error{{automatic variable qualified with an invalid address space}} |
| 211 |
@@ -208,10 +212,10 @@ void f(void) { |
| 212 |
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) |
| 213 |
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}} |
| 214 |
// expected-error@-3 {{variables in function scope cannot be declared static}} |
| 215 |
-#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) |
| 216 |
+#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ >= 300) |
| 217 |
#if !defined(__opencl_c_generic_address_space) |
| 218 |
-#if (__OPENCL_C_VERSION__ == 300) |
| 219 |
-// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}} |
| 220 |
+#if (__OPENCL_C_VERSION__ >= 300) |
| 221 |
+// expected-error-re@-7 {{OpenCL C version {{3.0|3.1}} does not support the 'generic' type qualifier}} |
| 222 |
#elif (__OPENCL_CPP_VERSION__ == 202100) |
| 223 |
// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}} |
| 224 |
#endif |
| 225 |
@@ -262,10 +266,10 @@ void f(void) { |
| 226 |
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) |
| 227 |
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}} |
| 228 |
// expected-error@-3 {{extern variable must reside in constant address space}} |
| 229 |
-#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) |
| 230 |
+#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ >= 300) |
| 231 |
#if !defined(__opencl_c_generic_address_space) |
| 232 |
-#if (__OPENCL_C_VERSION__ == 300) |
| 233 |
-// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}} |
| 234 |
+#if (__OPENCL_C_VERSION__ >= 300) |
| 235 |
+// expected-error-re@-7 {{OpenCL C version {{3.0|3.1}} does not support the 'generic' type qualifier}} |
| 236 |
#elif (__OPENCL_CPP_VERSION__ == 202100 && !defined(__opencl_c_generic_address_space)) |
| 237 |
// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}} |
| 238 |
#endif |
| 239 |
diff --git a/clang/test/SemaOpenCL/unsupported-image.cl b/clang/test/SemaOpenCL/unsupported-image.cl |
| 240 |
index 53422fa259f2..b67fce7952a2 100644 |
| 241 |
--- a/clang/test/SemaOpenCL/unsupported-image.cl |
| 242 |
+++ b/clang/test/SemaOpenCL/unsupported-image.cl |
| 243 |
@@ -1,6 +1,9 @@ |
| 244 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s |
| 245 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s |
| 246 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s |
| 247 |
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.1 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s |
| 248 |
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.1 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s |
| 249 |
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.1 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s |
| 250 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s |
| 251 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s |
| 252 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s |
| 253 |
-- |
| 254 |
2.53.0 |
| 255 |
|