diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9969,8 +9969,8 @@ if (getLangOpts().OpenCL && NewFD->hasAttr()) { // OpenCL v1.2 s6.8 static is invalid for kernel functions. - if ((getLangOpts().OpenCLVersion >= 120) - && (SC == SC_Static)) { + if ((getLangOpts().getOpenCLCompatibleVersion() >= 120) && + (SC == SC_Static)) { Diag(D.getIdentifierLoc(), diag::err_static_kernel); D.setInvalidType(); } diff --git a/clang/test/SemaOpenCL/storageclass-cl20.cl b/clang/test/SemaOpenCL/storageclass-cl20.cl --- a/clang/test/SemaOpenCL/storageclass-cl20.cl +++ b/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;