[PATCH] D109150: [OpenCL] Disallows static kernel functions in C++ for OpenCL
Justas Janickas via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 6 05:06:28 PDT 2021
Topotuna updated this revision to Diff 370895.
Topotuna added a comment.
Condition on OpenCL C / C++ for OpenCL version removed because it was redundant.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109150/new/
https://reviews.llvm.org/D109150
Files:
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaOpenCL/storageclass-cl20.cl
Index: clang/test/SemaOpenCL/storageclass-cl20.cl
===================================================================
--- clang/test/SemaOpenCL/storageclass-cl20.cl
+++ clang/test/SemaOpenCL/storageclass-cl20.cl
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
int G2 = 0;
global int G3 = 0;
@@ -18,6 +19,9 @@
extern private float g_private_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
extern generic float g_generic_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
+static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
+}
+
void kernel foo() {
constant int L1 = 0;
local int L2;
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9969,8 +9969,7 @@
if (getLangOpts().OpenCL && NewFD->hasAttr<OpenCLKernelAttr>()) {
// OpenCL v1.2 s6.8 static is invalid for kernel functions.
- if ((getLangOpts().OpenCLVersion >= 120)
- && (SC == SC_Static)) {
+ if (SC == SC_Static) {
Diag(D.getIdentifierLoc(), diag::err_static_kernel);
D.setInvalidType();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109150.370895.patch
Type: text/x-patch
Size: 1369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210906/0c5f4c28/attachment.bin>
More information about the cfe-commits
mailing list