[PATCH] D112110: [OpenCL] queue_t and ndrange_t can't be defined in program scope.
Chuang-Yu Cheng via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 27 15:19:35 PDT 2021
cycheng updated this revision to Diff 382816.
cycheng added a comment.
previous update was using wrong file, sorry!!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112110/new/
https://reviews.llvm.org/D112110
Files:
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaOpenCL/invalid-types.cl
Index: clang/test/SemaOpenCL/invalid-types.cl
===================================================================
--- /dev/null
+++ clang/test/SemaOpenCL/invalid-types.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_device_enqueue
+
+// Test declare "Other Data Type" variables in program scope.
+global queue_t qt; // expected-error {{the '__global queue_t' type cannot be used to declare a program scope variable}}
+
+typedef struct {int a;} ndrange_t;
+global ndrange_t qt; // expected-error {{the '__global ndrange_t' type cannot be used to declare a program scope variable}}
+
+typedef image2d_t test;
+global test qtt; // expected-error {{the '__global ndrange_t' type cannot be used to declare a program scope variable}}
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6841,8 +6841,12 @@
// OpenCL v2.0 s6.9.q:
// The clk_event_t and reserve_id_t types cannot be declared in program
// scope.
+ // OpenCL v3.0 s6.11.w:
+ // Program scope variables can be defined with any valid OpenCL C data type
+ // except for those in Other Built-in Data Types.
if (NewVD->hasGlobalStorage() && !NewVD->isStaticLocal()) {
- if (R->isReserveIDT() || R->isClkEventT() || R->isEventT()) {
+ if (R->isReserveIDT() || R->isClkEventT() || R->isEventT() ||
+ R->isQueueT() || R.getUnqualifiedType().getAsString() == "ndrange_t") {
Se.Diag(NewVD->getLocation(),
diag::err_invalid_type_for_program_scope_var)
<< R;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112110.382816.patch
Type: text/x-patch
Size: 1714 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211027/b96fa596/attachment.bin>
More information about the cfe-commits
mailing list