Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -6603,7 +6603,8 @@ } // OpenCL v1.1 s6.5.2 and s6.5.3 no local or constant variables // in functions. - if (T.getAddressSpace() == LangAS::opencl_constant || + if ((T.getAddressSpace() == LangAS::opencl_constant && + !NewVD->isLocalExternDecl()) || T.getAddressSpace() == LangAS::opencl_local) { FunctionDecl *FD = getCurFunctionDecl(); if (FD && !FD->hasAttr()) { Index: test/SemaOpenCL/extern.cl =================================================================== --- test/SemaOpenCL/extern.cl +++ test/SemaOpenCL/extern.cl @@ -7,3 +7,10 @@ kernel void test(global float* buf) { buf[0] += foo; } + +void test2(global float* buf) { +// CHECK: @bar = external addrspace(3) constant [0 x float] + extern constant float bar[]; + buf[0] += bar[0]; +} +